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

Database Keys With Examples Presentation (1)

Uploaded by

hce.ntd2021
Copyright
© © All Rights Reserved
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)
4 views

Database Keys With Examples Presentation (1)

Uploaded by

hce.ntd2021
Copyright
© © All Rights Reserved
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/ 9

Database Keys

Understanding Keys with Examples


What are Database Keys?
• • Database keys are attributes or sets of
attributes used to identify rows in a table.
• • They ensure data integrity and establish
relationships between tables.
• • Types include Primary Key, Foreign Key,
Candidate Key, Composite Key, and more.
Primary Key
• • A unique identifier for each row in a table.
• • Cannot contain duplicate or NULL values.

• Example:
• Table: Students
• Columns: Student_ID (Primary Key), Name,
Age
• | Student_ID | Name | Age |
• |------------|------------|-----|
Foreign Key
• • A key in one table that refers to the Primary
Key of another table.
• • Ensures referential integrity.

• Example:
• Table: Orders
• Columns: Order_ID, Product_ID, Customer_ID
(Foreign Key referencing Customers table)
Candidate Key
• • A set of attributes that can uniquely identify
rows in a table.
• • A table can have multiple candidate keys,
one of which becomes the Primary Key.

• Example:
• Table: Employees
• Columns: Employee_ID, Passport_Number,
Email
Composite Key
• • A key composed of two or more columns to
uniquely identify rows in a table.

• Example:
• Table: Enrollments
• Columns: Student_ID, Course_ID
• Composite Key: (Student_ID, Course_ID)
• | Student_ID | Course_ID |
• |------------|-----------|
Unique Key
• • Ensures all values in a column are unique.
• • Allows one NULL value (unlike the Primary
Key).

• Example:
• Table: Users
• Columns: User_ID (Primary Key), Email
(Unique Key)
• | User_ID | Email |
Super Key
• • A set of attributes that can uniquely identify
rows in a table.
• • Includes Primary Key and additional
attributes.

• Example:
• Table: Books
• Columns: ISBN (Primary Key), Title, Author
• Super Key: (ISBN), (ISBN, Title), (ISBN, Author)
Conclusion
• • Keys are crucial for maintaining data
integrity and relationships.
• • Understanding different types of keys helps
in database design.
• • Practice with real-world examples to master
these concepts.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy