1 / 9

KEYS IN DBMS

fjkfebeWKGB VBHOWIrnvWOIU4

Shubham54
Download Presentation

KEYS IN DBMS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. KEYS IN DBMS

  2. WHAT ARE KEYS? • KEYS in DBMS is an attribute or set of attributes which helps to identify a row(tuple) in a relation(table). • They allow us to find the relation between two tables.  • Key is helpful for finding unique record or row from the table.

  3. Dbms keys • DBMS has five types of keys in it and they all has different functionality. • The key are as follows: • Super Key • Primary Key • Candidate Key • Alternate Key • Foreign Key

  4. What is the Super key? • A super key is a set of all the keys (with single or multiple attributes) which can uniquely identify the records of the table. • In the above EMPLOYEE table, for(EMPLOEE_ID, EMPLOYEE_NAME), the name of two employees can be the same, but their EMPLYEE_ID can't be the same. Hence, this combination can also be a key.

  5. WHAT IS PRIMARY KEY? • A primary key is a column of a table or a set of columns that helps to identify every record present in that table uniquely. There can be only one primary Key in a table. • In the EMPLOYEE table, ID can be the primary key since it is unique for each employee. In the EMPLOYEE table, we can even select License_Number and Passport_Number as primary keys since they are also unique.

  6. WHAT IS CANDIDATE KEY? • A candidate key is an attribute or set of attributes that can uniquely identify a tuple. The candidate keys are as strong as the primary key. In the EMPLOYEE table, id is best suited for the primary key. The rest of the attributes, like SSN, Passport_Number, License_Number, etc., are considered a candidate key.

  7. WHAT IS ALTERNATE KEY? • An alternate key is the secondary candidate key that contains all the property of a candidate key but is an alternate option. • In this relation, Employee_Id is chosen as the primary key, so the other candidate key, PAN_No, acts as the Alternate key.

  8. WHAT IS FOREIGN KEY? • Foreign keys are the column of the table used to point to the primary key of another table. • Every employee works in a specific department in a company, and employee and department are two different entities. So we can't store the department's information in the employee table. That's why we link these two tables through the primary key of one table. We add the primary key of the DEPARTMENT table, Department_Id, as a new attribute in the EMPLOYEE table.In the EMPLOYEE table, Department_Id is the foreign key, and both the tables are related.

More Related