0% found this document useful (0 votes)
73 views

Keys and Integrity Rules

Keys are attributes that uniquely identify records in a database table. There are several types of keys: super keys identify each record but can include unnecessary attributes; candidate keys are minimal super keys; primary keys uniquely identify records and cannot be null; foreign keys link tables and must match the primary key of the related table; and composite keys use multiple attributes to uniquely identify records. Data integrity rules like entity integrity require primary keys be non-null and unique, while referential integrity requires foreign keys match an existing primary key value or be null.

Uploaded by

Swati Srivastava
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Keys and Integrity Rules

Keys are attributes that uniquely identify records in a database table. There are several types of keys: super keys identify each record but can include unnecessary attributes; candidate keys are minimal super keys; primary keys uniquely identify records and cannot be null; foreign keys link tables and must match the primary key of the related table; and composite keys use multiple attributes to uniquely identify records. Data integrity rules like entity integrity require primary keys be non-null and unique, while referential integrity requires foreign keys match an existing primary key value or be null.

Uploaded by

Swati Srivastava
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

KEYS AND INTEGRITY RULES

Presented By: Swati A1000712010 MCA-3A

What is a KEY ?
Key is a set of one or more columns whose combined values are unique among all occurrences in a given table.
Customer-street SSN Customer-city Customer-name customer

In this particular case, SSN can uniquely identify a particular customer.

TYPES OF KEYS :
Super Key Candidate Key Primary Key Foreign Key Composite key

SUPER KEY:
A Super key is any combination of fields within a table that uniquely identifies each record within that table.

CANDIDATE KEY:
A candidate is a subset of a super key. A candidate key is a single field or the least combination of fields that uniquely identifies each record in the table.

PRIMARY KEY:
o Primary key is the candidate key which is most appropriate to become main key of the table. It uniquely identifies each record in the table. o A primary key can consist of more than one field. o Primary key attributes cannot take null values.

FOREIGN KEY:
Foreign keys are the attributes of a table, which refers to the primary key of some another table. Foreign keys are used to link together two or more different tables which have some form of relationship with each other.

COMPOSITE KEY:
Sometimes it requires more than one attribute to uniquely identify an entity. A primary key that is made up of more than one attribute is known as a composite key.

DATA INTEGRITY RULES


Integrity constraints are used to ensure accuracy and consistency of data in a relational database.

TYPES:
Entity Integrity Referential Integrity

ENTITY INTEGRITY
A Primary Key must have a unique value & null values are not allowed, i.e. Primary keys must be NOT NULL. For example:

Record number 3 and 5 violates the rule of primary key because the Rollno is primary key, all the value of attributes are unique but their primary key entries are NULL and this violates the integrity rule 1, so these records are not allowed in RDBMS.

REFERENTIAL INTEGRITY
Foreign key values must always be present in the set of primary key values to which they are associated, or be null. For example

It should not be possible to create a staff record with branch number B025, unless there is already a record for branch number B025 in the Branch relation. However, we should be able to create a new staff record with a null branch number, to cater for the situation where a new member of staff has joined the company but has not yet been assigned to particular branch office.

THANKYOU

You might also like