SlideShare a Scribd company logo
1 of 21
The Relational Model
Logical View of Data
Keys
Integrity Rules
Relational Model:
Relational Model represents how data is stored in Relational Databases. A
relational database stores data in the form of relations (tables).
Objectives
- To promote high degree of data independence
- Eliminate redundancy and consistency problems.
- Ease of use of DBA as well as normal users.
- To provide a community view of the data of spartan simplicity, so that a wide
variety of users can interact with a common model.
The main use of Relational model is data storage and processing.
Relational Model
Relational Database:
A Relational database is a database that organizes data into tables which can be linked—
or related—based on data common to each.
Relational Database Components
1. Relation: A relation is nothing but a table with rows and columns.
2. Attributes: Attributes are the properties that define a relation.
3. Tuple: Each row in the relation is known as tuple.
4. Domain: A domain is a unique set of values permitted for an attribute in a table.
5. Degree: The number of attributes in a relation.
6. Cardinality: The number of tuples in a relation.
Relational Database
Properties of
Relations
• Relation name is distinct from all other relation
names in relational schema.
• Each cell of relation contains exactly one atomic
(single) value.
• Each attribute has a distinct name.
• Values of an attribute are all from the same domain.
• Each tuple is distinct; there are no duplicate tuples.
• Order of attributes has no significance.
• Order of tuples has no significance, theoretically.
• Key – every table must have a unique key to identify
each row
Relational Keys
• Key
A key is an attribute or set of attributes which helps us in uniquely identifying the
rows of a table. It also helps in establishing relationship among tables.
Types
i. Super Key
ii. Candidate Key
iii. Primary Key
iv. Foreign Key
v. Composite Key
Relational Keys
Super Key
A Super key or simply key is a
combination of all possible attribute which
can uniquely identify the rows(tuples) in a
table. This means that a super key may
Have some extra attribute which isn’t
Necessary for uniquely identifying
the rows in the table.
Super Key
Candidate Key
Candidate Key is a set of attributes that uniquely identify tuples in a table.
Candidate Key is a super key with no repeated attributes. The Primary key should
be selected from the candidate keys. Every table must have at least a single
candidate key.
Candidate Key
Primary Key
Primary Key is a column/ that uniquely identify every row in that table.
The Primary Key can't be a duplicate meaning the same value can't appear
more than once in the table. A table cannot have more than one primary
key.
Primary Key
Alternate/Secondary Key
All the candidate key which are not a primary key are called an alternate
key.
Alternate/Secondary Key
Foreign Key is a column/attribute that
creates a relationship between two
tables. The purpose of Foreign keys is to
maintain data integrity and allow
navigation between two different
instances of an entity. It acts as a cross-
reference between two tables as it
references the primary
key of another table.
Foreign Key
Composite Key
A key that has more than one attributes is known as composite key. It is
also known as compound key.
Any key such as super key, primary key, candidate key etc. can be called
composite key if it has more than one attributes.
Composite Key
None of these columns alone can play a role of key in this table.
Key in above table: {cust_id, product_code}
This is a composite key as it is made up of more than one attributes.
Composite Key(cont.)
Composite Key (cont.)
A relation schema represents name of the relation with its attributes.
So, A set of table attributes is called a relation schema. For that reason, a relation
schema is also known as table schema. A relation schema can be thought of as the
basic information describing a table or relation. Hence, it is the logical definition of a
table.
e.g.; STUDENT (ROLL_NO, NAME, ADDRESS, PHONE and AGE) is a relation schema
for STUDENT.
If a schema has more than 1 relation, it is called Relational Schema aka Database
Schema. You could say that a database schema is made up of lots of relation
schema and shows how they work together.
Relation Schema
Integrity
Rules
Integrity rules refer to reliability, validity and
authority towards the data. They needed to
inform the DBMS about certain constraints in the
real world.
There are two principal rules:
1. Entity integrity &
2. Referential integrity
For Entity Integrity Rule, each table has a Primary Key and the Primary Key can not have a
Null value.
<Student>
Above, you can see our primary key is Student_ID. We cannot consider Student_Awards
as the primary key since not every student would have received the award.
<Employee>
In the above table, Employee_ID is the primary key.
Entity Integrity Rule
Student_ID Student_Name Student_Awards
Employee_ID Employee_Name Employee_Age Employee_Location
So let us now summarize the Entity Integrity Rule −
i. Make sure that each tuple in a table is unique.
ii. Every table mush has a primary key, for example, Student_ID for a Student
table.
iii. Every entity is unique.
iv. The relations Primary Key must have unique values for each row.
v. Primary Key cannot have NULL value and must be unique.
vi. Example can be an Employee_ID cannot be null in an Employee table
Entity Integrity (cont.)
Referential Integrity Rule in DBMS is based on Primary and Foreign Key. The Rule
defines that a foreign key have a matching primary key. Reference from a table to
another table should be valid.
Referential Integrity Rule
The rule states that
the DEPT_ID in the Employee
table has a matching
valid DEPT_ID in
the Department table.
To allow join, the referential
integrity rule states that the
Primary Key and Foreign Key
have same data types.
These are additional rules specified by users or database administrators that
define or constraint some aspect of the enterprise.
They are alsoknown as business rules.
For example :
The Cust_No in Customer table is given a range from 0001-5000.
General Constraints
Thank you.

More Related Content

What's hot (20)

ER DIAGRAM & ER MODELING IN DBMS
ER DIAGRAM & ER MODELING IN DBMSER DIAGRAM & ER MODELING IN DBMS
ER DIAGRAM & ER MODELING IN DBMS
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
 
Integrity constraints in dbms
Integrity constraints in dbmsIntegrity constraints in dbms
Integrity constraints in dbms
 
data modeling and models
data modeling and modelsdata modeling and models
data modeling and models
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
 
DBMS Keys
DBMS KeysDBMS Keys
DBMS Keys
 
Data models
Data modelsData models
Data models
 
Entity relationship modelling
Entity relationship modellingEntity relationship modelling
Entity relationship modelling
 
Dbms database models
Dbms database modelsDbms database models
Dbms database models
 
Database Keys
Database KeysDatabase Keys
Database Keys
 
Databases: Normalisation
Databases: NormalisationDatabases: Normalisation
Databases: Normalisation
 
Key and its different types
Key and its different typesKey and its different types
Key and its different types
 
Data models
Data modelsData models
Data models
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data Model
 
All data models in dbms
All data models in dbmsAll data models in dbms
All data models in dbms
 
DBMS: Types of keys
DBMS:  Types of keysDBMS:  Types of keys
DBMS: Types of keys
 
Dbms architecture
Dbms architectureDbms architecture
Dbms architecture
 
Basic DBMS ppt
Basic DBMS pptBasic DBMS ppt
Basic DBMS ppt
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
 

Similar to The Relational Model: Logical View of Data, Keys, Integrity Rules

Types of keys in dbms
Types of keys in dbmsTypes of keys in dbms
Types of keys in dbmsdarshhingu
 
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESDATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESNathRam2
 
Module 2 dbms.pptx
Module 2 dbms.pptxModule 2 dbms.pptx
Module 2 dbms.pptxVijishK
 
Intro to Data warehousing lecture 12
Intro to Data warehousing   lecture 12Intro to Data warehousing   lecture 12
Intro to Data warehousing lecture 12AnwarrChaudary
 
Whats the Schema Table Column Row Attribute Entity Pri.pdf
Whats the Schema  Table  Column  Row  Attribute  Entity  Pri.pdfWhats the Schema  Table  Column  Row  Attribute  Entity  Pri.pdf
Whats the Schema Table Column Row Attribute Entity Pri.pdfexxonzone
 
2.2 keys
2.2 keys2.2 keys
2.2 keysELIMENG
 
Understanding Entity Relationship Models
Understanding Entity Relationship ModelsUnderstanding Entity Relationship Models
Understanding Entity Relationship ModelsHamzaNadeem527928
 
RELATIONSHIP IN DBMS.pptx
RELATIONSHIP IN DBMS.pptxRELATIONSHIP IN DBMS.pptx
RELATIONSHIP IN DBMS.pptxKAnurag2
 
Databases - Unit 2.pdf
Databases - Unit 2.pdfDatabases - Unit 2.pdf
Databases - Unit 2.pdfCynthiaAdzornu
 

Similar to The Relational Model: Logical View of Data, Keys, Integrity Rules (20)

B & c
B & cB & c
B & c
 
DBMS-Unit-2.pptx
DBMS-Unit-2.pptxDBMS-Unit-2.pptx
DBMS-Unit-2.pptx
 
Relational Model
Relational ModelRelational Model
Relational Model
 
The Relational Model
The Relational ModelThe Relational Model
The Relational Model
 
Types of keys in dbms
Types of keys in dbmsTypes of keys in dbms
Types of keys in dbms
 
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESDATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
 
Module 2 dbms.pptx
Module 2 dbms.pptxModule 2 dbms.pptx
Module 2 dbms.pptx
 
Intro to Data warehousing lecture 12
Intro to Data warehousing   lecture 12Intro to Data warehousing   lecture 12
Intro to Data warehousing lecture 12
 
DBMS Unit 2 ppt.ppt
DBMS Unit 2 ppt.pptDBMS Unit 2 ppt.ppt
DBMS Unit 2 ppt.ppt
 
Whats the Schema Table Column Row Attribute Entity Pri.pdf
Whats the Schema  Table  Column  Row  Attribute  Entity  Pri.pdfWhats the Schema  Table  Column  Row  Attribute  Entity  Pri.pdf
Whats the Schema Table Column Row Attribute Entity Pri.pdf
 
2.2 keys
2.2 keys2.2 keys
2.2 keys
 
Understanding Entity Relationship Models
Understanding Entity Relationship ModelsUnderstanding Entity Relationship Models
Understanding Entity Relationship Models
 
computer-210809080138.pdf
computer-210809080138.pdfcomputer-210809080138.pdf
computer-210809080138.pdf
 
RELATIONSHIP IN DBMS.pptx
RELATIONSHIP IN DBMS.pptxRELATIONSHIP IN DBMS.pptx
RELATIONSHIP IN DBMS.pptx
 
Dbms keysppt
Dbms keyspptDbms keysppt
Dbms keysppt
 
key.pptx
key.pptxkey.pptx
key.pptx
 
Keys in Database
Keys in DatabaseKeys in Database
Keys in Database
 
Databases - Unit 2.pdf
Databases - Unit 2.pdfDatabases - Unit 2.pdf
Databases - Unit 2.pdf
 
Keys.pptx
Keys.pptxKeys.pptx
Keys.pptx
 
DATABASE DESIGN.pptx
DATABASE DESIGN.pptxDATABASE DESIGN.pptx
DATABASE DESIGN.pptx
 

More from Shishir Aryal

Nikola tesla (The master of Lightening)
Nikola tesla (The master of Lightening)Nikola tesla (The master of Lightening)
Nikola tesla (The master of Lightening)Shishir Aryal
 
How does blockchain work
How does blockchain workHow does blockchain work
How does blockchain workShishir Aryal
 
Total quality management
Total quality management Total quality management
Total quality management Shishir Aryal
 
Von-Neumann machine and IAS architecture
Von-Neumann machine and  IAS architectureVon-Neumann machine and  IAS architecture
Von-Neumann machine and IAS architectureShishir Aryal
 
Non verbal communication
Non verbal communicationNon verbal communication
Non verbal communicationShishir Aryal
 
Intercultural communication shishir
Intercultural communication shishirIntercultural communication shishir
Intercultural communication shishirShishir Aryal
 
Public key encryption presentation
Public key encryption presentationPublic key encryption presentation
Public key encryption presentationShishir Aryal
 

More from Shishir Aryal (8)

Nikola tesla (The master of Lightening)
Nikola tesla (The master of Lightening)Nikola tesla (The master of Lightening)
Nikola tesla (The master of Lightening)
 
Stuxnet
StuxnetStuxnet
Stuxnet
 
How does blockchain work
How does blockchain workHow does blockchain work
How does blockchain work
 
Total quality management
Total quality management Total quality management
Total quality management
 
Von-Neumann machine and IAS architecture
Von-Neumann machine and  IAS architectureVon-Neumann machine and  IAS architecture
Von-Neumann machine and IAS architecture
 
Non verbal communication
Non verbal communicationNon verbal communication
Non verbal communication
 
Intercultural communication shishir
Intercultural communication shishirIntercultural communication shishir
Intercultural communication shishir
 
Public key encryption presentation
Public key encryption presentationPublic key encryption presentation
Public key encryption presentation
 

Recently uploaded

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 

The Relational Model: Logical View of Data, Keys, Integrity Rules

  • 1. The Relational Model Logical View of Data Keys Integrity Rules
  • 2. Relational Model: Relational Model represents how data is stored in Relational Databases. A relational database stores data in the form of relations (tables). Objectives - To promote high degree of data independence - Eliminate redundancy and consistency problems. - Ease of use of DBA as well as normal users. - To provide a community view of the data of spartan simplicity, so that a wide variety of users can interact with a common model. The main use of Relational model is data storage and processing. Relational Model
  • 3. Relational Database: A Relational database is a database that organizes data into tables which can be linked— or related—based on data common to each. Relational Database Components 1. Relation: A relation is nothing but a table with rows and columns. 2. Attributes: Attributes are the properties that define a relation. 3. Tuple: Each row in the relation is known as tuple. 4. Domain: A domain is a unique set of values permitted for an attribute in a table. 5. Degree: The number of attributes in a relation. 6. Cardinality: The number of tuples in a relation. Relational Database
  • 4.
  • 5.
  • 6. Properties of Relations • Relation name is distinct from all other relation names in relational schema. • Each cell of relation contains exactly one atomic (single) value. • Each attribute has a distinct name. • Values of an attribute are all from the same domain. • Each tuple is distinct; there are no duplicate tuples. • Order of attributes has no significance. • Order of tuples has no significance, theoretically. • Key – every table must have a unique key to identify each row
  • 7. Relational Keys • Key A key is an attribute or set of attributes which helps us in uniquely identifying the rows of a table. It also helps in establishing relationship among tables. Types i. Super Key ii. Candidate Key iii. Primary Key iv. Foreign Key v. Composite Key Relational Keys
  • 8. Super Key A Super key or simply key is a combination of all possible attribute which can uniquely identify the rows(tuples) in a table. This means that a super key may Have some extra attribute which isn’t Necessary for uniquely identifying the rows in the table. Super Key
  • 9. Candidate Key Candidate Key is a set of attributes that uniquely identify tuples in a table. Candidate Key is a super key with no repeated attributes. The Primary key should be selected from the candidate keys. Every table must have at least a single candidate key. Candidate Key
  • 10. Primary Key Primary Key is a column/ that uniquely identify every row in that table. The Primary Key can't be a duplicate meaning the same value can't appear more than once in the table. A table cannot have more than one primary key. Primary Key
  • 11. Alternate/Secondary Key All the candidate key which are not a primary key are called an alternate key. Alternate/Secondary Key
  • 12. Foreign Key is a column/attribute that creates a relationship between two tables. The purpose of Foreign keys is to maintain data integrity and allow navigation between two different instances of an entity. It acts as a cross- reference between two tables as it references the primary key of another table. Foreign Key
  • 13. Composite Key A key that has more than one attributes is known as composite key. It is also known as compound key. Any key such as super key, primary key, candidate key etc. can be called composite key if it has more than one attributes. Composite Key
  • 14. None of these columns alone can play a role of key in this table. Key in above table: {cust_id, product_code} This is a composite key as it is made up of more than one attributes. Composite Key(cont.) Composite Key (cont.)
  • 15. A relation schema represents name of the relation with its attributes. So, A set of table attributes is called a relation schema. For that reason, a relation schema is also known as table schema. A relation schema can be thought of as the basic information describing a table or relation. Hence, it is the logical definition of a table. e.g.; STUDENT (ROLL_NO, NAME, ADDRESS, PHONE and AGE) is a relation schema for STUDENT. If a schema has more than 1 relation, it is called Relational Schema aka Database Schema. You could say that a database schema is made up of lots of relation schema and shows how they work together. Relation Schema
  • 16. Integrity Rules Integrity rules refer to reliability, validity and authority towards the data. They needed to inform the DBMS about certain constraints in the real world. There are two principal rules: 1. Entity integrity & 2. Referential integrity
  • 17. For Entity Integrity Rule, each table has a Primary Key and the Primary Key can not have a Null value. <Student> Above, you can see our primary key is Student_ID. We cannot consider Student_Awards as the primary key since not every student would have received the award. <Employee> In the above table, Employee_ID is the primary key. Entity Integrity Rule Student_ID Student_Name Student_Awards Employee_ID Employee_Name Employee_Age Employee_Location
  • 18. So let us now summarize the Entity Integrity Rule − i. Make sure that each tuple in a table is unique. ii. Every table mush has a primary key, for example, Student_ID for a Student table. iii. Every entity is unique. iv. The relations Primary Key must have unique values for each row. v. Primary Key cannot have NULL value and must be unique. vi. Example can be an Employee_ID cannot be null in an Employee table Entity Integrity (cont.)
  • 19. Referential Integrity Rule in DBMS is based on Primary and Foreign Key. The Rule defines that a foreign key have a matching primary key. Reference from a table to another table should be valid. Referential Integrity Rule The rule states that the DEPT_ID in the Employee table has a matching valid DEPT_ID in the Department table. To allow join, the referential integrity rule states that the Primary Key and Foreign Key have same data types.
  • 20. These are additional rules specified by users or database administrators that define or constraint some aspect of the enterprise. They are alsoknown as business rules. For example : The Cust_No in Customer table is given a range from 0001-5000. General Constraints