Page 163 - IT-802_class_12
P. 163

However {Gender, Salary} is not a superkey because both these attributes have identical values for employees
                 Neha and Himani.

            Ð Ð Key:  It  is  the  minimal  super  key,  which  means  it  is  the  superkey  of  a  relation  from  which,  if  any  attribute  is
              removed, it no longer remains a superkey. For example, the superkey {Name, Employee_ID, Gender} is not a key
              as we can remove Name and Gender from this combination and then what is left {Employee_ID} is still a superkey.
              Now {Employee_ID} is a key as it is a superkey as well as no more removals are possible. A relation may have
              more than one key. Consider the relation PERSON with the following schema: PERSON (Aadhar_number, PAN,
              Voter_ID_cardno, Name, Date_of_birth, Address). This relation has three keys namely: {Aadhar number}, {PAN},
              {Voter_ID_no} as every individual in India has a unique Aadhar card number, PAN as well as Voter ID card number.

            Ð Ð Candidate key: A candidate key is an attribute or set of attributes that uniquely identifies a row. For example, the
              PERSON relation has three candidate keys as discussed above.

            Ð Ð Primary Key: One of the candidate keys may be designated as the Primary key. Primary key is used to identify tuples
              in a relation. If a relation has many candidate keys it is preferable to choose that one as the primary key which has
              the least number of attributes.

               Primary key is usually underlined in the schema of the relation. For example, in the relation schema: PERSON
              (Aadhar number, PAN, Voter_ID_cardno, Name,  Date_of_birth, Address), Aadhar number is the primary key.
              The relation between super key, key, candidate key and primary key can be explained with the help of Figure.
                                                                               Primary Key



                                                    Candidate
                                                       Keys                         Key


                                                    Super Keys


            Ð Ð Null Value Constraint: Sometimes it is required that certain attributes cannot have null values. For example, if every
              EMPLOYEE must have a valid name, then the Name attribute is constrained to be NOT NULL.

            Ð Ð Entity Integrity Constraint: This constraint specifies that the primary key of a relation cannot have a NULL value.
              The reason behind this constraint is that we know the primary key contains no duplicates. However, if we allow
              null values for a primary key then there can be multiple tuples for which the primary key is having null values. This
              would imply that we are allowing duplicate values (NULL) for a primary key which itself violates the definition of
              the primary key.

            Ð Ð Referential Integrity Constraint: This constraint is specified between two relations. Before defining this constraint
              let us study the concept of foreign keys.
            Foreign key in a relation R1 is the set of attributes in R1 that refer to the primary key in another relation R2 if the
            domain of foreign key attributes is the same as that of primary key attributes and the value of foreign key either occurs
            as a value of primary key in some tuple of R2 or is NULL. R1 is called the referencing relation and R2 is called referenced
            relation, and a referential integrity constraint holds from R1 to R2.

            The main purpose of this constraint is to check that data entered in one relation is consistent with the data entered in
            another relation. For example, consider two relations schemas:
              (a) Department (Dept_Name, Dept_ID, No_of_Teachers)
              (b) Teacher (Teacher_Name, Teacher_ID, Dept_ID, Subject)





                                                                                 Database Concepts—RDBMS Tool   161
   158   159   160   161   162   163   164   165   166   167   168