top of page
Data on a Touch Pad

RDBMS FUNDAMENTALS

KEY or CONSTRAINT

•    A constraint is the restriction imposed on the field of a table.
•    It is an identifier used to derive records from a table uniquely.
•    Types of constraints:-
    I.    Unique:-
        •    When a field is declared with unique constraint, it is known as unique key field.
        •    It allows a single unique value to enter into a field. That means, it can’t store duplicate value.
        •    It allows a single blank value.
    II.  Not null:-
        •    A not null constraint does not allow NULL value into a field.
        •    A not null field allows duplicate values.
    III. Primary key:-
        •    A primary key is a key/constraint that can uniquely identify a record from table.
        •    A primary key is the combination of unique and not null key.
              UNIQUE + NOT NULL --> PRIMARY KEY
        •    A primary key field must have unique value and it does not allow any null value.
        •    Types of primary key:-
            There are two types of primary key:-
                a.    Simple key:-
                A single column primary key is called as simple key.

tab1.JPG

                b.    Composite key:-
                A multi-column primary key is called as composite key.

tab2.JPG

    IV.   Foreign key:-
        •    A foreign key is a constraint used on a child table.
        •    A foreign key field links two or more tables to ensure data integrity.
        •    So that, it is also known as referential integrity constraint.
        •    A foreign key is also a primary key in another table (parent table).
        •    A foreign key field may allow multiple values in the child table but that value must be present in the primary key of the parent table.
    V.   Candidate key:-
        •    A candidate key is a key that is used to identify each record uniquely from a table in the absence of primary key.
    VI. Alternate key:-
        •    In a table there may be more than one candidate key.
        •    In the absence of primary key, only one of the candidate key can be used as a primary key to identify each record from a table uniquely and rest of the candidate keys are called as alternate key.
  VII. Check:-
        •    A check constraint is a constraint imposed on afield to check the entry value into the field within the specified values.
        •    For example; mark (check mark between 0 and 100).
 VIII. Default:-
        •    It is a constraint imposed on a field of a table to assign a default value to that field when there is no data entry from the user.

Related Topics:

bottom of page