Posts

Showing posts from July, 2018

What is basic SELECT statement?

Image
SELECT Statement
A SELECT statement retrieves data from the database. With SELECT statement PROJECTION, SELECTION and JOIN can be performed on database tables.
As data in relational database is stored in TABLES. TABLE has ROW and COLUMN structure. With SELECT statement all rows and all columns can be retrieved, this is known as PROJECTION. But, if rows and columns are retrieved on the basis of some condition, it is known as SELECTION. And suppose if some information is needed and that is stored in two or more different tables but are related, use JOINS to retrieve it from two or more tables.
In SQL, basic SELECT statements are as follows:
SELECT * FROM [table_name];
SELECT[column1][column2][column3],..... FROM  [table_name];
SELECT and FROM are known as clauses. 
SELECT clause allows to specify columns to be selected from the database table. 
FROM clause allows to specify table name that has those column to be selected.
Semicolon at the end of SELECT statement specify the end of SQL statemen…

What are the types of Functional Dependency?

Image
Types of Functional DependencyThere are basically two types of functional dependency, 
Trivial Functional DependencyNontrivial Functional Dependency
A functional dependency A à B is a trivial, if B is a subset of A. 
It means dependent is  a subset of determinant or right term is a subset of left term. That is trivial, and is not so important. As B is a subset of A, which we already know and so we are not getting any new thing.
A functional dependency A à B is a nontrivial, if B is not a subset of A.
It means dependent is not a subset of determinant or right term is not a subset of left term. That is nontrivial, and is important. As B is not a subset of A, which we don't know and so we are getting something new.

Example of Trivial FD:
{EM_NO, EM_NAME}à {EM_NAME}



Example of Nontrivial FD:
{EM_NO }à {EM_NAME}



What do you mean by Functional Dependency?

Image
Functional DependencyIn a relation schemaR with two attribute sets A and B, where A and  B are subsets of R, then relation R holds a functional dependency, 

Such that, if any valid relation r(R), with two tuples t1 and t2, has                                            t1[A] = t2[A]
then it should also have,                                             t1[B] = t2[B]                                   
That means value of every tuple of attribute set B is dependent on value of every tuple of attribute set A,
or 
That means every tuple of attribute A determines the value of every tuple of attribute set B.
In simple terms, if we know the value of A, then we can find the value of B in any relation R. 
To understand it more clearly, let us take a simple example:
Consider a table T1 with only two columns C1 and C2  
C1