***Welcome to ashrafedu.blogspot.com * * * This website is maintained by ASHRAF***

Posts

    Monday, 7 June 2021

    Keys

    Key: Each row has one or more attributes, known as relation key, which can identify the row in the relation (table) uniquely. A key is subet of attributes from the attributes of relation.

    A key in a relation uniquely identifies a tuple in a relation.

    The different types of keys in DBMS are:

    1)      Super Key - Super Key is the superset of primary key. The super key contains a set of attributes, including the primary key, which can uniquely identify any data row in the table. A Super key may have additional attributes that are not needed for unique identification.

    2)      Candidate Key - The candidate keys in a table are defined as the set of keys that is minimal and can uniquely identify any data row in the table.

    3)      Primary Key - The primary key is selected from one of the candidate keys and becomes the identifying key of a table. It can uniquely identify any data row of the table.

    Rules for defining Primary key:

    ·         Two rows can't have the same primary key value

    ·         Every row must to have a primary key value.

    ·         The primary key field cannot be null.

    ·         The value in a primary key column can never be modified or updated if any foreign key refers to that primary key.

    4)      Secondary Key - Only one of the candidate keys is selected as the primary key. The rest of them are known as secondary keys.

    5)      Foreign Key - A foreign key is an attribute value in a table that acts as the primary key in another another. Hence, the foreign key is useful in linking together two tables. Data should be entered in the foreign key column with great care, as wrongly entered data can invalidate the relationship between the two tables.


    6)      Composite Key - If any single attribute of a table is not capable of being the key i.e it cannot identify a row uniquely, then we combine two or more attributes to form a key. This is known as a composite key.




    No comments:

    Post a Comment