SlideShare a Scribd company logo
1 of 24
Relational Model
Rajeev Srivastava
ToC
• Relation
• Tuples
• Cardinality
• Attribute
• Degree/Arity
• Domains
• Relation vs. Table
2
• Candidate Key
• Super Key
• Primary Key
• Composite Key
• Foreign Key
• Integrity Rules
RAJEEVS@CDAC.IN
Relation
In Relational Model data is modelled in form of Relations represented by tabular
structure.
Consider the relation EMPLOYEE represented by the following table:
3
EmpCode Name Desig Grade JoinDate BasicSalary Gender DeptCode
RAJEEVS@CDAC.IN
Tuples in a Relation
A relation is a set of tuples; each row here is a tuple :
4
EmpCode Name Desig Grade JoinDate BasicSalary Gender DeptCode
1
2
3
4
5
7
6
RAJEEVS@CDAC.IN
Cardinality of a Relation
No of Tuples in a Relation at a point in time.
Cardinality = 7
5
EmpCode Name Desig Grade JoinDate BasicSalary Gender DeptCode
1
2
3
4
5
7
6
RAJEEVS@CDAC.IN
Attribute in a Relation
An attribute represents a quality/information about an entity.
A tuple consists of Attribute values.
6
EmpCode Name Desig Grade JoinDate BasicSalary Gender DeptCode
RAJEEVS@CDAC.IN
Degree (=Arity) of a Relation
A degree or arity of a Relation is the number of attributes in it.
Degree = 8
7
EmpCode Name Desig Grade JoinDate BasicSalary Gender DeptCode
RAJEEVS@CDAC.IN
Domains
Each attribute has a domain associated with it.
Attribute values in a relation are restricted to the values from its domain.
8
EmpCode Name Desig Grade JoinDate BasicSalary Gender DeptCode
DEPT
ACCO
PURC
COUR
DESIG
PE
TO
STO
RAJEEVS@CDAC.IN
Consider the Employee relation defined as :
create table EMPLOYEE(
EmpCode integer(4),
Name char(30),
Desig char(4),
Grade integer(4),
JoinDate date,
Basic integer(7),
Gender char(1),
DeptCode char(4) )
9RAJEEVS@CDAC.IN
Domains of Attributes of Employee Relation :
EmpCode set of all 4-digit numbers
Name set of all 30-alpha characters
Desig set of all designation codes
Grade set of all grade values
JoinDate set of all dates (in a given range)
Basic set of all possible values for basic
Gender set {'M','F‘, ‘T’}
DeptCode set of all dept codes
10RAJEEVS@CDAC.IN
A Relation may be represented as a Table where
11
Relation Table
Tuple Row/Record
Attribute Column
Degree/Arity No of Columns in the table
Cardinality No or Rows in the table
Domain Pool of acceptable values for a
column
Primary Key Unique Identifier
RAJEEVS@CDAC.IN
But, a Relation is not a Table, because :
• A table has an inherent order for rows; there is no concept of order for tuples
in a relation.
• A relation must have a primary key; a table need not have an identifier.
• The tuples in a relation must be unique; there is no such restriction for tables
12RAJEEVS@CDAC.IN
Relation : Observations
• A Relation is a set of tuples.
• A Relation is time-variant.
• A Relation cannot have duplicate tuples.
• Tuples in a Relation are unordered.
• Values are Atomic.
• Attribute values are of same kind.
• A Relation is a subset of the Cartesian Product of a set of domains.
13RAJEEVS@CDAC.IN
Candidate Key & Super Key
A set of attributes is said to be Candidate Key if and only if it satisfies the
following time-independent properties:
Uniqueness property: No two distinct tuples have the same value for the key.
Minimality property: None of the attributes of the key can be discarded from
the key without destroying the uniqueness property.
A Super Key is a Non-Minimal Candidate Key. Its a set of one or more columns in
a table for which no two rows can have the exact same values.
An Alternate Key is a candidate key that is not the primary key.
14RAJEEVS@CDAC.IN
Candidate Key?
create table EMPLOYEE(
EmpCode integer(4),
Name char(30),
Desig char(4),
Grade integer(4),
JoinDate date,
Basic integer(7),
Gender char(1),
DeptCode char(4) )
15RAJEEVS@CDAC.IN
Candidate Key?
create table EMPLOYEE (
EmpCode integer(4),
Name char(30),
Desig char(4),
Grade integer(4),
JoinDate date,
Basic integer(7),
Gender char(1),
DeptCode char(4),
Email char(100),
MobileNo char(16) )
16RAJEEVS@CDAC.IN
Primary Key
is a candidate key that have following two qualities -
• Uniquely identifies a tuple in a relation
• Must NOT be NULL
*Should be selected from candidate keys such that it never/rarely changes.
17RAJEEVS@CDAC.IN
Primary Key?
create table EMPLOYEE (
EmpCode integer(4),
Name char(30),
Desig char(4),
Grade integer(4),
JoinDate date,
Basic integer(7),
Gender char(1),
DeptCode char(4),
Email char(100),
MobileNo char(16) )
18RAJEEVS@CDAC.IN
Composite Key
• A candidate key with two or more attributes that uniquely identifies the tuple in a
Relation.
• Also called as compound key
Composite Primary Key
• A primary key which is a composite key is called as Composite Primary Key.
19RAJEEVS@CDAC.IN
Can we have more than one primary key
in a table?
No. We can not.
People who are new to RDBMS are often get confused with the restriction of single Primary Key
in a table and the concept of Composite Key. To clarify the same -
A table can have only one Primary Key.
The Primary Key can be defined on a single column or more than one columns. If the Primary
Key is defined using more that one columns, it is known as a Composite Key (or Composite
Primary Key).
Therefore, a Composite Key in a table does not mean that there are more than one Primary Keys
in the table. Instead, a Composite Key uses more than one columns to define a (Single) Primary
Key.
RAJEEVS@CDAC.IN 20
Foreign Key
• A Foreign Key is a set of attributes in one relation whose values are required to match
one of the values of the primary key of the same or different relation.
• There can be more than one foreign key in a given relation.
21RAJEEVS@CDAC.IN
Identify a relation in any system/business, define its
Attributes, Domain for each attribute and find out Primary,
Key, Foreign Keys, Candidate Keys, Super Key in the relation.
Foreign Key(s)?
create table EMPLOYEE(
EmpCode integer(4),
Name char(30),
Desig char(4),
Grade integer(4),
JoinDate date,
Basic integer(7)),
Gender char(1),
DeptCode char(4) )
create table DEPT(
DeptCode char(4),
DeptName char(30),
Location char(10) )
22RAJEEVS@CDAC.IN
Integrity Rules
Entity Integrity: Implemented through Primary Key
“No Attribute participating in the primary key of a relation may accept null
values”
Guarantees that each tuple will have a unique identity.
Referential Integrity: Implemented through Foreign Key
“Values of the foreign key (a) must be either null, or (b) if non-null, must match
with the primary key value of some tuple of the `parent’ relation. The reference
can be to the same relation”
*Foreign Key is also know as Reference/Referential key.
23RAJEEVS@CDAC.IN
Relational Database Operations
• SELECTION: This selects some or all of the records in a table.
Through WHERE Clause
• PROJECTION: This limits columns from a table.
Through SELECT Clause
• UNION
• INTERSECTION
• DIFFERENCE
• JOIN
• CARTESIAN PRODUCT
RAJEEVS@CDAC.IN 24

More Related Content

What's hot

Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Eddyzulham Mahluzydde
 
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database ConstraintsThe Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraintssontumax
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relationalJafar Nesargi
 
4 the relational data model and relational database constraints
4 the relational data model and relational database constraints4 the relational data model and relational database constraints
4 the relational data model and relational database constraintsKumar
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]Bashir Rezaie
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMSkoolkampus
 
Lecture 07 relational database management system
Lecture 07 relational database management systemLecture 07 relational database management system
Lecture 07 relational database management systememailharmeet
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data ModelSmriti Jain
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...Mustafa Kamel Mohammadi
 
Chapter-6 Relational Algebra
Chapter-6 Relational AlgebraChapter-6 Relational Algebra
Chapter-6 Relational AlgebraKunal Anand
 
Chapter 2 Relational Data Model-part 2
Chapter 2 Relational Data Model-part 2Chapter 2 Relational Data Model-part 2
Chapter 2 Relational Data Model-part 2Eddyzulham Mahluzydde
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelKunal Anand
 
Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)Vidyasagar Mundroy
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization TechniquesNishant Munjal
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relationalJafar Nesargi
 
Chapter-9 Normalization
Chapter-9 NormalizationChapter-9 Normalization
Chapter-9 NormalizationKunal Anand
 
Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013Prosanta Ghosh
 
Chapter-8 Relational Database Design
Chapter-8 Relational Database DesignChapter-8 Relational Database Design
Chapter-8 Relational Database DesignKunal Anand
 
Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2eidah20
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational modelChirag vasava
 

What's hot (20)

Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1
 
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database ConstraintsThe Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraints
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
 
4 the relational data model and relational database constraints
4 the relational data model and relational database constraints4 the relational data model and relational database constraints
4 the relational data model and relational database constraints
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
 
Lecture 07 relational database management system
Lecture 07 relational database management systemLecture 07 relational database management system
Lecture 07 relational database management system
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data Model
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...
 
Chapter-6 Relational Algebra
Chapter-6 Relational AlgebraChapter-6 Relational Algebra
Chapter-6 Relational Algebra
 
Chapter 2 Relational Data Model-part 2
Chapter 2 Relational Data Model-part 2Chapter 2 Relational Data Model-part 2
Chapter 2 Relational Data Model-part 2
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data Model
 
Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
 
Chapter-9 Normalization
Chapter-9 NormalizationChapter-9 Normalization
Chapter-9 Normalization
 
Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013
 
Chapter-8 Relational Database Design
Chapter-8 Relational Database DesignChapter-8 Relational Database Design
Chapter-8 Relational Database Design
 
Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 

Similar to Relational Model Fundamentals

Advance database system(part 5)
Advance database system(part 5)Advance database system(part 5)
Advance database system(part 5)Abdullah Khosa
 
4_RelationalDataModelAndRelationalMapping.pdf
4_RelationalDataModelAndRelationalMapping.pdf4_RelationalDataModelAndRelationalMapping.pdf
4_RelationalDataModelAndRelationalMapping.pdfLPhct2
 
Integrity Constraints in Database Management System.ppt
Integrity Constraints in Database Management System.pptIntegrity Constraints in Database Management System.ppt
Integrity Constraints in Database Management System.pptRoshni814224
 
2. relational model_150903
2. relational model_1509032. relational model_150903
2. relational model_150903Dika Handika
 
5. relational structure
5. relational structure5. relational structure
5. relational structurekhoahuy82
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database ModelShishir Aryal
 
8. OPERATORS IN SQL.pptx
8.  OPERATORS IN SQL.pptx8.  OPERATORS IN SQL.pptx
8. OPERATORS IN SQL.pptxRenugadeviR5
 
Structured Query Language (SQL) - An Introduction
Structured Query Language (SQL) - An IntroductionStructured Query Language (SQL) - An Introduction
Structured Query Language (SQL) - An IntroductionRajeev Srivastava
 
Relational Model on Database management PPT
Relational Model on Database management PPTRelational Model on Database management PPT
Relational Model on Database management PPTssuser3e0f731
 
Relational model
Relational modelRelational model
Relational modelRUpaliLohar
 
Relational model
Relational modelRelational model
Relational modelRUpaliLohar
 
Eer >r.model
Eer >r.modelEer >r.model
Eer >r.modellavya3
 
Relational database management system
Relational database management systemRelational database management system
Relational database management systemPraveen Soni
 

Similar to Relational Model Fundamentals (20)

Advance database system(part 5)
Advance database system(part 5)Advance database system(part 5)
Advance database system(part 5)
 
Data model
Data modelData model
Data model
 
DBMS-Unit-2.pptx
DBMS-Unit-2.pptxDBMS-Unit-2.pptx
DBMS-Unit-2.pptx
 
4_RelationalDataModelAndRelationalMapping.pdf
4_RelationalDataModelAndRelationalMapping.pdf4_RelationalDataModelAndRelationalMapping.pdf
4_RelationalDataModelAndRelationalMapping.pdf
 
Integrity Constraints in Database Management System.ppt
Integrity Constraints in Database Management System.pptIntegrity Constraints in Database Management System.ppt
Integrity Constraints in Database Management System.ppt
 
2. relational model_150903
2. relational model_1509032. relational model_150903
2. relational model_150903
 
Create table
Create tableCreate table
Create table
 
5. relational structure
5. relational structure5. relational structure
5. relational structure
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 
8. OPERATORS IN SQL.pptx
8.  OPERATORS IN SQL.pptx8.  OPERATORS IN SQL.pptx
8. OPERATORS IN SQL.pptx
 
RDBMS
RDBMSRDBMS
RDBMS
 
Structured Query Language (SQL) - An Introduction
Structured Query Language (SQL) - An IntroductionStructured Query Language (SQL) - An Introduction
Structured Query Language (SQL) - An Introduction
 
Relational Model on Database management PPT
Relational Model on Database management PPTRelational Model on Database management PPT
Relational Model on Database management PPT
 
ER diagram
ER diagramER diagram
ER diagram
 
Relational model
Relational modelRelational model
Relational model
 
Relational model
Relational modelRelational model
Relational model
 
Integrity and security
Integrity and securityIntegrity and security
Integrity and security
 
DBMS.pptx
DBMS.pptxDBMS.pptx
DBMS.pptx
 
Eer >r.model
Eer >r.modelEer >r.model
Eer >r.model
 
Relational database management system
Relational database management systemRelational database management system
Relational database management system
 

Recently uploaded

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
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging 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
 
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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

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...
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
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
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
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
 
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
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

Relational Model Fundamentals

  • 2. ToC • Relation • Tuples • Cardinality • Attribute • Degree/Arity • Domains • Relation vs. Table 2 • Candidate Key • Super Key • Primary Key • Composite Key • Foreign Key • Integrity Rules RAJEEVS@CDAC.IN
  • 3. Relation In Relational Model data is modelled in form of Relations represented by tabular structure. Consider the relation EMPLOYEE represented by the following table: 3 EmpCode Name Desig Grade JoinDate BasicSalary Gender DeptCode RAJEEVS@CDAC.IN
  • 4. Tuples in a Relation A relation is a set of tuples; each row here is a tuple : 4 EmpCode Name Desig Grade JoinDate BasicSalary Gender DeptCode 1 2 3 4 5 7 6 RAJEEVS@CDAC.IN
  • 5. Cardinality of a Relation No of Tuples in a Relation at a point in time. Cardinality = 7 5 EmpCode Name Desig Grade JoinDate BasicSalary Gender DeptCode 1 2 3 4 5 7 6 RAJEEVS@CDAC.IN
  • 6. Attribute in a Relation An attribute represents a quality/information about an entity. A tuple consists of Attribute values. 6 EmpCode Name Desig Grade JoinDate BasicSalary Gender DeptCode RAJEEVS@CDAC.IN
  • 7. Degree (=Arity) of a Relation A degree or arity of a Relation is the number of attributes in it. Degree = 8 7 EmpCode Name Desig Grade JoinDate BasicSalary Gender DeptCode RAJEEVS@CDAC.IN
  • 8. Domains Each attribute has a domain associated with it. Attribute values in a relation are restricted to the values from its domain. 8 EmpCode Name Desig Grade JoinDate BasicSalary Gender DeptCode DEPT ACCO PURC COUR DESIG PE TO STO RAJEEVS@CDAC.IN
  • 9. Consider the Employee relation defined as : create table EMPLOYEE( EmpCode integer(4), Name char(30), Desig char(4), Grade integer(4), JoinDate date, Basic integer(7), Gender char(1), DeptCode char(4) ) 9RAJEEVS@CDAC.IN
  • 10. Domains of Attributes of Employee Relation : EmpCode set of all 4-digit numbers Name set of all 30-alpha characters Desig set of all designation codes Grade set of all grade values JoinDate set of all dates (in a given range) Basic set of all possible values for basic Gender set {'M','F‘, ‘T’} DeptCode set of all dept codes 10RAJEEVS@CDAC.IN
  • 11. A Relation may be represented as a Table where 11 Relation Table Tuple Row/Record Attribute Column Degree/Arity No of Columns in the table Cardinality No or Rows in the table Domain Pool of acceptable values for a column Primary Key Unique Identifier RAJEEVS@CDAC.IN
  • 12. But, a Relation is not a Table, because : • A table has an inherent order for rows; there is no concept of order for tuples in a relation. • A relation must have a primary key; a table need not have an identifier. • The tuples in a relation must be unique; there is no such restriction for tables 12RAJEEVS@CDAC.IN
  • 13. Relation : Observations • A Relation is a set of tuples. • A Relation is time-variant. • A Relation cannot have duplicate tuples. • Tuples in a Relation are unordered. • Values are Atomic. • Attribute values are of same kind. • A Relation is a subset of the Cartesian Product of a set of domains. 13RAJEEVS@CDAC.IN
  • 14. Candidate Key & Super Key A set of attributes is said to be Candidate Key if and only if it satisfies the following time-independent properties: Uniqueness property: No two distinct tuples have the same value for the key. Minimality property: None of the attributes of the key can be discarded from the key without destroying the uniqueness property. A Super Key is a Non-Minimal Candidate Key. Its a set of one or more columns in a table for which no two rows can have the exact same values. An Alternate Key is a candidate key that is not the primary key. 14RAJEEVS@CDAC.IN
  • 15. Candidate Key? create table EMPLOYEE( EmpCode integer(4), Name char(30), Desig char(4), Grade integer(4), JoinDate date, Basic integer(7), Gender char(1), DeptCode char(4) ) 15RAJEEVS@CDAC.IN
  • 16. Candidate Key? create table EMPLOYEE ( EmpCode integer(4), Name char(30), Desig char(4), Grade integer(4), JoinDate date, Basic integer(7), Gender char(1), DeptCode char(4), Email char(100), MobileNo char(16) ) 16RAJEEVS@CDAC.IN
  • 17. Primary Key is a candidate key that have following two qualities - • Uniquely identifies a tuple in a relation • Must NOT be NULL *Should be selected from candidate keys such that it never/rarely changes. 17RAJEEVS@CDAC.IN
  • 18. Primary Key? create table EMPLOYEE ( EmpCode integer(4), Name char(30), Desig char(4), Grade integer(4), JoinDate date, Basic integer(7), Gender char(1), DeptCode char(4), Email char(100), MobileNo char(16) ) 18RAJEEVS@CDAC.IN
  • 19. Composite Key • A candidate key with two or more attributes that uniquely identifies the tuple in a Relation. • Also called as compound key Composite Primary Key • A primary key which is a composite key is called as Composite Primary Key. 19RAJEEVS@CDAC.IN
  • 20. Can we have more than one primary key in a table? No. We can not. People who are new to RDBMS are often get confused with the restriction of single Primary Key in a table and the concept of Composite Key. To clarify the same - A table can have only one Primary Key. The Primary Key can be defined on a single column or more than one columns. If the Primary Key is defined using more that one columns, it is known as a Composite Key (or Composite Primary Key). Therefore, a Composite Key in a table does not mean that there are more than one Primary Keys in the table. Instead, a Composite Key uses more than one columns to define a (Single) Primary Key. RAJEEVS@CDAC.IN 20
  • 21. Foreign Key • A Foreign Key is a set of attributes in one relation whose values are required to match one of the values of the primary key of the same or different relation. • There can be more than one foreign key in a given relation. 21RAJEEVS@CDAC.IN Identify a relation in any system/business, define its Attributes, Domain for each attribute and find out Primary, Key, Foreign Keys, Candidate Keys, Super Key in the relation.
  • 22. Foreign Key(s)? create table EMPLOYEE( EmpCode integer(4), Name char(30), Desig char(4), Grade integer(4), JoinDate date, Basic integer(7)), Gender char(1), DeptCode char(4) ) create table DEPT( DeptCode char(4), DeptName char(30), Location char(10) ) 22RAJEEVS@CDAC.IN
  • 23. Integrity Rules Entity Integrity: Implemented through Primary Key “No Attribute participating in the primary key of a relation may accept null values” Guarantees that each tuple will have a unique identity. Referential Integrity: Implemented through Foreign Key “Values of the foreign key (a) must be either null, or (b) if non-null, must match with the primary key value of some tuple of the `parent’ relation. The reference can be to the same relation” *Foreign Key is also know as Reference/Referential key. 23RAJEEVS@CDAC.IN
  • 24. Relational Database Operations • SELECTION: This selects some or all of the records in a table. Through WHERE Clause • PROJECTION: This limits columns from a table. Through SELECT Clause • UNION • INTERSECTION • DIFFERENCE • JOIN • CARTESIAN PRODUCT RAJEEVS@CDAC.IN 24