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 s

What do you mean by Functional Dependency?

Functional Dependency

In a relation schema R 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
C2
P
1
Q
2
R
3
S
4

In this case, if we know the value of column C1 we can find the value of C2, therefore  C1à C2. Therefore, C2 is functionally dependent on C1.

But, if the table is like below, then

C1
C2
P
1
P
2
R
3
S
4

Not possible to find the value of C2 from C1. In case of C1 = P, it has two Ps with two different values of C2, 1 and 2. Even if we know the value of C1 that is P, we are not able to determine C2, whether it is 1 or 2. 

So, in this case C1 is not able to determine the value of C2 and hance C2 is not functionally dependent on C1.


Comments

Popular posts from this blog

With the help of block diagram explain the architecture of a DBMS.

What do you mean by data model? What are different types of data models?

Define the terms: domain, tuple, attribute and relation