SlideShare a Scribd company logo
1 of 41
Department of Information Technology 1Data base Technologies (ITB4201)
Relational Database Design
Dr. C.V. Suresh Babu
Professor
Department of IT
Hindustan Institute of Science & Technology
Department of Information Technology 2Data base Technologies (ITB4201)
Action Plan
• Need for Relational Database Design
• Primary key
• Foreign keys
• Many-to-one relationships
• Many-to-many relationships
• Referential Integrity
• Queries and Joins
• Quiz
Department of Information Technology 3Data base Technologies (ITB4201)
Objectives of logical design...
• Translate the conceptual design into a logical database design that
can be implemented on a chosen DBMS
– Input: conceptual model (ERD)
– Output: relational schema, normalized relations
• Resulting database must meet user needs for:
– Data sharing
– Ease of access
– Flexibility
Department of Information Technology 4Data base Technologies (ITB4201)
Relational database components
• Data structure
– Data organized into tables
• Data manipulation
– Add, delete, modify, and retrieve using SQL
• Data integrity
– Maintained using business rules
Department of Information Technology 5Data base Technologies (ITB4201)
Why do I need to know this?
• Mapping conceptual models to relational schema is straight-forward
• CASE tools can perform many of the steps, but..
– Often CASE cannot model complexity of data and relationship (e.G.,
Ternary relationships, supertype/subtypes)
– There are times when legitimate alternates must be evaluated
– You must be able to perform a quality check on CASE tool results
Department of Information Technology 6Data base Technologies (ITB4201)
Some rules...
• Every table has a unique name.
• Attributes in tables have unique names.
• Every attribute value is atomic.
– Multi-valued and composite attributes?
• Every row is unique.
• The order of the columns is irrelevant.
• The order of the rows is irrelevant.
Department of Information Technology 7Data base Technologies (ITB4201)
The key...
• Relational modeling uses primary keys and foreign
keys to maintain relationships
• Primary keys are typically the unique identifier
noted on the conceptual model
• Foreign keys are the primary key of another entity
to which an entity has a relationship
• Composite keys are primary keys that are made of
more than one attribute
– Weak entities
– Associative entities
Department of Information Technology 8Data base Technologies (ITB4201)
Implementing it
Instance
Attribute
Entity
Field
Department of Information Technology 9Data base Technologies (ITB4201)
What about relationships?
Department of Information Technology 10Data base Technologies (ITB4201)
Constraints
• Domain constraints
– Allowable values for an attribute as defined in
the domain
• Entity integrity constraints
– No primary key attribute may be null
• Operational constraints
– Business rules
• Referential integrity constraints
Department of Information Technology 11Data base Technologies (ITB4201)
Referential integrity constraint
• Maintains consistency among rows of two
entities
– matching of primary and foreign keys
• Enforcement options for deleting instances
– Restrict
– Cascade
– Set-to-Null
Department of Information Technology 12Data base Technologies (ITB4201)
Transforming the EER diagram into relations
The steps:
• Map regular entities
• Map weak entities
• Map binary relationships
• Map associative entities
• Map unary relationships
• Map ternary relationships
• Map supertype/subtype relationships
Department of Information Technology 13Data base Technologies (ITB4201)
Transforming E-R diagrams into relations
Mapping regular entities to relations
–Composite attributes: use only their simple, component
attributes
–Multi-valued attributes: become a separate relation with a
foreign key taken from the superior entity
Department of Information Technology 14Data base Technologies (ITB4201)
Mapping a composite attribute
Department of Information Technology 15Data base Technologies (ITB4201)
Looks like this using relational schema notation
Department of Information Technology 16Data base Technologies (ITB4201)
Transforming E-R diagrams into relations
Mapping weak entities
–Becomes a separate relation with a foreign key taken from
the superior entity
Department of Information Technology 17Data base Technologies (ITB4201)
Example of mapping a weak entity
Department of Information Technology 18Data base Technologies (ITB4201)
Looks like this using relational schema notation
Department of Information Technology 19Data base Technologies (ITB4201)
Transforming E-R diagrams into relations
Mapping binary relationships
– One-to-many - primary key on the one side becomes a foreign key on the many
side
– Many-to-many - create a new relation (associative entity) with the primary
keys of the two entities as its primary key
• I like to call these intersection entities to distinguish them from associative
entities created at the conceptual level
– One-to-one - primary key on the mandatory side becomes a foreign key on the
optional side
Department of Information Technology 20Data base Technologies (ITB4201)
Example of mapping a 1:M relationship
Department of Information Technology 21Data base Technologies (ITB4201)
Looks like this using relational schema notation
Department of Information Technology 22Data base Technologies (ITB4201)
Example of mapping an M:M relationship
Department of Information Technology 23Data base Technologies (ITB4201)
Looks like this using relational schema notation
Department of Information Technology 24Data base Technologies (ITB4201)
Mapping a binary 1:1 relationship
Department of Information Technology 25Data base Technologies (ITB4201)
Looks like this using relational schema notation
Department of Information Technology 26Data base Technologies (ITB4201)
Transforming E-R diagrams into relations
Mapping associative entities
– Identifier not assigned
• Default primary key for the association relation is the primary keys
of the two entities
– Identifier assigned
• It is natural and familiar to end-users
• Default identifier may not be unique
Department of Information Technology 27Data base Technologies (ITB4201)
Mapping an associative entity with an identifier
Department of Information Technology 28Data base Technologies (ITB4201)
Looks like this using relational schema notation
Department of Information Technology 29Data base Technologies (ITB4201)
Transforming E-R diagrams into relations
Mapping unary relationships
– One-to-many - recursive foreign key in the same relation
– Many-to-many - two relations:
• One for the entity type
• One for an associative relation in which the primary key has two
attributes, both taken from the primary key of the entity
Department of Information Technology 30Data base Technologies (ITB4201)
For example...
EMPLOYEE
SupervisesEmp-Name
Emp_Address
Emp_Num
Department of Information Technology 31Data base Technologies (ITB4201)
Would look like...
Emp_Num Emp_Name Emp_Address Boss_Num
references
Department of Information Technology 32Data base Technologies (ITB4201)
And..
COMPONENT
BOMDescription
Unit_of-Measure
Comp_Num
Num_Units
Department of Information Technology 33Data base Technologies (ITB4201)
Would look like...
Comp_Num Desc Unit_of_Measure
COMPONENT
Num-of_Units Comp_Num Subassembly_Num
BOM
Department of Information Technology 34Data base Technologies (ITB4201)
Transforming E-R diagrams into relations
Mapping ternary (and n-ary) relationships
–One relation for each entity and one for the associative
entity
Department of Information Technology 35Data base Technologies (ITB4201)
Mapping a ternary relationship
Department of Information Technology 36Data base Technologies (ITB4201)
Looks like this using relational schema notation
Department of Information Technology 37Data base Technologies (ITB4201)
Transforming E-R diagrams into relations
Mapping Supertype/subtype relationships
–Create a separate relation for the supertype and each of the
subtypes
–Assign common attributes to supertype
–Assign primary key and unique attributes to each subtype
–Assign an attribute of the supertype to act as subtype
discriminator
Department of Information Technology 38Data base Technologies (ITB4201)
Mapping Supertype/subtype relationships
Department of Information Technology 39Data base Technologies (ITB4201)
Would look like this...
Department of Information Technology 40Data base Technologies (ITB4201)
Test Yourself
1. In a relational database a referential integrity constraint can be specified with the help of:
a) primary key
b) foreign key
c) secondary key
d) none of the above
1. Which of the following is not a feature of a god relational design?
a) Specifying primary keys
b) Specifying foreign keys
c) Preserving integrity constraints
d) Allowing redundancy of attributes
2. The dependency rules specified by the database designer is known as:
a) Designer dependencies
b) Database rules
c) Functional dependencies
d) None of the mentioned
1. Address field of a person should not be part of primary key, since it is likely to be:
a) Dependent
b) Too Long
c) Changed
d) Not Changed
5. A table is a collection of relationships, there is a close correspondence between concept of:
a) Tables and instances
b) Tables and variables
c) Tables and relations
d) Tables and entities
Department of Information Technology 41Data base Technologies (ITB4201)
Answers
1. In a relational database a referential integrity constraint can be specified with the help of:
a) primary key
b) foreign key
c) secondary key
d) none of the above
1. Which of the following is not a feature of a god relational design?
a) Specifying primary keys
b) Specifying foreign keys
c) Preserving integrity constraints
d) Allowing redundancy of attributes
2. The dependency rules specified by the database designer is known as:
a) Designer dependencies
b) Database rules
c) Functional dependencies
d) None of the mentioned
1. Address field of a person should not be part of primary key, since it is likely to be:
a) Dependent
b) Too Long
c) Changed
d) Not Changed
5. A table is a collection of relationships, there is a close correspondence between concept of:
a) Tables and instances
b) Tables and variables
c) Tables and relations
d) Tables and entities

More Related Content

What's hot

Database Design and the ER Model, Indexing and Hashing
Database Design and the ER Model, Indexing and HashingDatabase Design and the ER Model, Indexing and Hashing
Database Design and the ER Model, Indexing and HashingPrabu U
 
Basic database analysis(database)
Basic database analysis(database)Basic database analysis(database)
Basic database analysis(database)welcometofacebook
 
[Www.pkbulk.blogspot.com]dbms03
[Www.pkbulk.blogspot.com]dbms03[Www.pkbulk.blogspot.com]dbms03
[Www.pkbulk.blogspot.com]dbms03AnusAhmad
 
2003-An adaptive nearest neighbor search for a parts acquisition ePortal-p693...
2003-An adaptive nearest neighbor search for a parts acquisition ePortal-p693...2003-An adaptive nearest neighbor search for a parts acquisition ePortal-p693...
2003-An adaptive nearest neighbor search for a parts acquisition ePortal-p693...Hua Li, PhD
 
Phone Book project in Data Structure C
Phone  Book  project in Data Structure CPhone  Book  project in Data Structure C
Phone Book project in Data Structure CVaithekyAnandarajah
 
Improved Presentation and Facade Layer Operations for Software Engineering Pr...
Improved Presentation and Facade Layer Operations for Software Engineering Pr...Improved Presentation and Facade Layer Operations for Software Engineering Pr...
Improved Presentation and Facade Layer Operations for Software Engineering Pr...Dr. Amarjeet Singh
 
IRJET- Techniques for Detecting and Extracting Tabular Data from PDFs and Sca...
IRJET- Techniques for Detecting and Extracting Tabular Data from PDFs and Sca...IRJET- Techniques for Detecting and Extracting Tabular Data from PDFs and Sca...
IRJET- Techniques for Detecting and Extracting Tabular Data from PDFs and Sca...IRJET Journal
 
Coit11237 assignment 2 specifications
Coit11237 assignment 2 specificationsCoit11237 assignment 2 specifications
Coit11237 assignment 2 specificationsNicole Valerio
 
All data models in dbms
All data models in dbmsAll data models in dbms
All data models in dbmsNaresh Kumar
 
A survey of top k query processing techniques in relational database systems
A survey of top k query processing techniques in relational database systemsA survey of top k query processing techniques in relational database systems
A survey of top k query processing techniques in relational database systemsunyil96
 
Ppt of dbms e r features
Ppt of dbms e r featuresPpt of dbms e r features
Ppt of dbms e r featuresNirali Akabari
 
Introduction to Data warehousiing and Mining
Introduction to Data warehousiing and MiningIntroduction to Data warehousiing and Mining
Introduction to Data warehousiing and MiningDr. C.V. Suresh Babu
 
Software Engineering Ontology
Software Engineering OntologySoftware Engineering Ontology
Software Engineering OntologyNidhi Baranwal
 
split up syllabus_ip,cs-xi,xii
split up syllabus_ip,cs-xi,xiisplit up syllabus_ip,cs-xi,xii
split up syllabus_ip,cs-xi,xiiSooraj Mohan
 

What's hot (20)

Database Design and the ER Model, Indexing and Hashing
Database Design and the ER Model, Indexing and HashingDatabase Design and the ER Model, Indexing and Hashing
Database Design and the ER Model, Indexing and Hashing
 
Basic database analysis(database)
Basic database analysis(database)Basic database analysis(database)
Basic database analysis(database)
 
[Www.pkbulk.blogspot.com]dbms03
[Www.pkbulk.blogspot.com]dbms03[Www.pkbulk.blogspot.com]dbms03
[Www.pkbulk.blogspot.com]dbms03
 
Chapter 9
Chapter 9Chapter 9
Chapter 9
 
2003-An adaptive nearest neighbor search for a parts acquisition ePortal-p693...
2003-An adaptive nearest neighbor search for a parts acquisition ePortal-p693...2003-An adaptive nearest neighbor search for a parts acquisition ePortal-p693...
2003-An adaptive nearest neighbor search for a parts acquisition ePortal-p693...
 
A018110108
A018110108A018110108
A018110108
 
Phone Book project in Data Structure C
Phone  Book  project in Data Structure CPhone  Book  project in Data Structure C
Phone Book project in Data Structure C
 
Improved Presentation and Facade Layer Operations for Software Engineering Pr...
Improved Presentation and Facade Layer Operations for Software Engineering Pr...Improved Presentation and Facade Layer Operations for Software Engineering Pr...
Improved Presentation and Facade Layer Operations for Software Engineering Pr...
 
IRJET- Techniques for Detecting and Extracting Tabular Data from PDFs and Sca...
IRJET- Techniques for Detecting and Extracting Tabular Data from PDFs and Sca...IRJET- Techniques for Detecting and Extracting Tabular Data from PDFs and Sca...
IRJET- Techniques for Detecting and Extracting Tabular Data from PDFs and Sca...
 
Coit11237 assignment 2 specifications
Coit11237 assignment 2 specificationsCoit11237 assignment 2 specifications
Coit11237 assignment 2 specifications
 
Distributed databases
Distributed  databasesDistributed  databases
Distributed databases
 
SECh78
SECh78SECh78
SECh78
 
All data models in dbms
All data models in dbmsAll data models in dbms
All data models in dbms
 
A survey of top k query processing techniques in relational database systems
A survey of top k query processing techniques in relational database systemsA survey of top k query processing techniques in relational database systems
A survey of top k query processing techniques in relational database systems
 
Sq lite module3
Sq lite module3Sq lite module3
Sq lite module3
 
Ppt of dbms e r features
Ppt of dbms e r featuresPpt of dbms e r features
Ppt of dbms e r features
 
Introduction to Data warehousiing and Mining
Introduction to Data warehousiing and MiningIntroduction to Data warehousiing and Mining
Introduction to Data warehousiing and Mining
 
Software Engineering Ontology
Software Engineering OntologySoftware Engineering Ontology
Software Engineering Ontology
 
split up syllabus_ip,cs-xi,xii
split up syllabus_ip,cs-xi,xiisplit up syllabus_ip,cs-xi,xii
split up syllabus_ip,cs-xi,xii
 
Datastage database design and data modeling ppt 4
Datastage database design and data modeling ppt 4Datastage database design and data modeling ppt 4
Datastage database design and data modeling ppt 4
 

Similar to Relational database design

ICT DBA3 03 0710 Designing a Database.pptx
ICT DBA3 03 0710 Designing a Database.pptxICT DBA3 03 0710 Designing a Database.pptx
ICT DBA3 03 0710 Designing a Database.pptxInfotech27
 
Making connections matter: 2 use cases on graphs & analytics solutions
Making connections matter: 2 use cases on graphs & analytics solutionsMaking connections matter: 2 use cases on graphs & analytics solutions
Making connections matter: 2 use cases on graphs & analytics solutionsNeo4j
 
2019MS EXAM REPORT20161K_unit14_pef_20190313 (1).pdf
2019MS EXAM REPORT20161K_unit14_pef_20190313 (1).pdf2019MS EXAM REPORT20161K_unit14_pef_20190313 (1).pdf
2019MS EXAM REPORT20161K_unit14_pef_20190313 (1).pdfDorinNguema
 
PPT Lecture 2.1 and 2.2 DataModels.ppt
PPT Lecture 2.1 and 2.2 DataModels.pptPPT Lecture 2.1 and 2.2 DataModels.ppt
PPT Lecture 2.1 and 2.2 DataModels.pptprateek720399
 
IT6701 Information Management - Unit I
IT6701 Information Management - Unit I  IT6701 Information Management - Unit I
IT6701 Information Management - Unit I pkaviya
 
Syllabus mca 2 rdbms i
Syllabus mca 2 rdbms iSyllabus mca 2 rdbms i
Syllabus mca 2 rdbms iemailharmeet
 
SOFTWARE ENGINEERING ppt
SOFTWARE ENGINEERING pptSOFTWARE ENGINEERING ppt
SOFTWARE ENGINEERING pptHarshita Bansal
 
Database architecture and Data modelling
 Database architecture and Data modelling Database architecture and Data modelling
Database architecture and Data modellingViswanathanS21
 
Data Lineage, Property Based Testing & Neo4j
Data Lineage, Property Based Testing & Neo4j Data Lineage, Property Based Testing & Neo4j
Data Lineage, Property Based Testing & Neo4j Neo4j
 

Similar to Relational database design (20)

Normalization
NormalizationNormalization
Normalization
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
 
Indexing
IndexingIndexing
Indexing
 
ICT DBA3 03 0710 Designing a Database.pptx
ICT DBA3 03 0710 Designing a Database.pptxICT DBA3 03 0710 Designing a Database.pptx
ICT DBA3 03 0710 Designing a Database.pptx
 
SQL
SQL SQL
SQL
 
FDS_dept_ppt.pptx
FDS_dept_ppt.pptxFDS_dept_ppt.pptx
FDS_dept_ppt.pptx
 
Seng 123 9-iid
Seng 123 9-iidSeng 123 9-iid
Seng 123 9-iid
 
Making connections matter: 2 use cases on graphs & analytics solutions
Making connections matter: 2 use cases on graphs & analytics solutionsMaking connections matter: 2 use cases on graphs & analytics solutions
Making connections matter: 2 use cases on graphs & analytics solutions
 
2019MS EXAM REPORT20161K_unit14_pef_20190313 (1).pdf
2019MS EXAM REPORT20161K_unit14_pef_20190313 (1).pdf2019MS EXAM REPORT20161K_unit14_pef_20190313 (1).pdf
2019MS EXAM REPORT20161K_unit14_pef_20190313 (1).pdf
 
Sq lite module4
Sq lite module4Sq lite module4
Sq lite module4
 
Chapter 1- IT.pptx
Chapter 1- IT.pptxChapter 1- IT.pptx
Chapter 1- IT.pptx
 
PPT Lecture 2.1 and 2.2 DataModels.ppt
PPT Lecture 2.1 and 2.2 DataModels.pptPPT Lecture 2.1 and 2.2 DataModels.ppt
PPT Lecture 2.1 and 2.2 DataModels.ppt
 
IT6701 Information Management - Unit I
IT6701 Information Management - Unit I  IT6701 Information Management - Unit I
IT6701 Information Management - Unit I
 
Syllabus mca 2 rdbms i
Syllabus mca 2 rdbms iSyllabus mca 2 rdbms i
Syllabus mca 2 rdbms i
 
SOFTWARE ENGINEERING ppt
SOFTWARE ENGINEERING pptSOFTWARE ENGINEERING ppt
SOFTWARE ENGINEERING ppt
 
E R model
E R modelE R model
E R model
 
Database architecture and Data modelling
 Database architecture and Data modelling Database architecture and Data modelling
Database architecture and Data modelling
 
Data Lineage, Property Based Testing & Neo4j
Data Lineage, Property Based Testing & Neo4j Data Lineage, Property Based Testing & Neo4j
Data Lineage, Property Based Testing & Neo4j
 
03 chapter
03 chapter03 chapter
03 chapter
 
Presentation of se
Presentation of sePresentation of se
Presentation of se
 

More from Dr. C.V. Suresh Babu (20)

Data analytics with R
Data analytics with RData analytics with R
Data analytics with R
 
Association rules
Association rulesAssociation rules
Association rules
 
Clustering
ClusteringClustering
Clustering
 
Classification
ClassificationClassification
Classification
 
Blue property assumptions.
Blue property assumptions.Blue property assumptions.
Blue property assumptions.
 
Introduction to regression
Introduction to regressionIntroduction to regression
Introduction to regression
 
DART
DARTDART
DART
 
Mycin
MycinMycin
Mycin
 
Expert systems
Expert systemsExpert systems
Expert systems
 
Dempster shafer theory
Dempster shafer theoryDempster shafer theory
Dempster shafer theory
 
Bayes network
Bayes networkBayes network
Bayes network
 
Bayes' theorem
Bayes' theoremBayes' theorem
Bayes' theorem
 
Knowledge based agents
Knowledge based agentsKnowledge based agents
Knowledge based agents
 
Rule based system
Rule based systemRule based system
Rule based system
 
Formal Logic in AI
Formal Logic in AIFormal Logic in AI
Formal Logic in AI
 
Production based system
Production based systemProduction based system
Production based system
 
Game playing in AI
Game playing in AIGame playing in AI
Game playing in AI
 
Diagnosis test of diabetics and hypertension by AI
Diagnosis test of diabetics and hypertension by AIDiagnosis test of diabetics and hypertension by AI
Diagnosis test of diabetics and hypertension by AI
 
A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”
 
A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”
 

Recently uploaded

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Recently uploaded (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

Relational database design

  • 1. Department of Information Technology 1Data base Technologies (ITB4201) Relational Database Design Dr. C.V. Suresh Babu Professor Department of IT Hindustan Institute of Science & Technology
  • 2. Department of Information Technology 2Data base Technologies (ITB4201) Action Plan • Need for Relational Database Design • Primary key • Foreign keys • Many-to-one relationships • Many-to-many relationships • Referential Integrity • Queries and Joins • Quiz
  • 3. Department of Information Technology 3Data base Technologies (ITB4201) Objectives of logical design... • Translate the conceptual design into a logical database design that can be implemented on a chosen DBMS – Input: conceptual model (ERD) – Output: relational schema, normalized relations • Resulting database must meet user needs for: – Data sharing – Ease of access – Flexibility
  • 4. Department of Information Technology 4Data base Technologies (ITB4201) Relational database components • Data structure – Data organized into tables • Data manipulation – Add, delete, modify, and retrieve using SQL • Data integrity – Maintained using business rules
  • 5. Department of Information Technology 5Data base Technologies (ITB4201) Why do I need to know this? • Mapping conceptual models to relational schema is straight-forward • CASE tools can perform many of the steps, but.. – Often CASE cannot model complexity of data and relationship (e.G., Ternary relationships, supertype/subtypes) – There are times when legitimate alternates must be evaluated – You must be able to perform a quality check on CASE tool results
  • 6. Department of Information Technology 6Data base Technologies (ITB4201) Some rules... • Every table has a unique name. • Attributes in tables have unique names. • Every attribute value is atomic. – Multi-valued and composite attributes? • Every row is unique. • The order of the columns is irrelevant. • The order of the rows is irrelevant.
  • 7. Department of Information Technology 7Data base Technologies (ITB4201) The key... • Relational modeling uses primary keys and foreign keys to maintain relationships • Primary keys are typically the unique identifier noted on the conceptual model • Foreign keys are the primary key of another entity to which an entity has a relationship • Composite keys are primary keys that are made of more than one attribute – Weak entities – Associative entities
  • 8. Department of Information Technology 8Data base Technologies (ITB4201) Implementing it Instance Attribute Entity Field
  • 9. Department of Information Technology 9Data base Technologies (ITB4201) What about relationships?
  • 10. Department of Information Technology 10Data base Technologies (ITB4201) Constraints • Domain constraints – Allowable values for an attribute as defined in the domain • Entity integrity constraints – No primary key attribute may be null • Operational constraints – Business rules • Referential integrity constraints
  • 11. Department of Information Technology 11Data base Technologies (ITB4201) Referential integrity constraint • Maintains consistency among rows of two entities – matching of primary and foreign keys • Enforcement options for deleting instances – Restrict – Cascade – Set-to-Null
  • 12. Department of Information Technology 12Data base Technologies (ITB4201) Transforming the EER diagram into relations The steps: • Map regular entities • Map weak entities • Map binary relationships • Map associative entities • Map unary relationships • Map ternary relationships • Map supertype/subtype relationships
  • 13. Department of Information Technology 13Data base Technologies (ITB4201) Transforming E-R diagrams into relations Mapping regular entities to relations –Composite attributes: use only their simple, component attributes –Multi-valued attributes: become a separate relation with a foreign key taken from the superior entity
  • 14. Department of Information Technology 14Data base Technologies (ITB4201) Mapping a composite attribute
  • 15. Department of Information Technology 15Data base Technologies (ITB4201) Looks like this using relational schema notation
  • 16. Department of Information Technology 16Data base Technologies (ITB4201) Transforming E-R diagrams into relations Mapping weak entities –Becomes a separate relation with a foreign key taken from the superior entity
  • 17. Department of Information Technology 17Data base Technologies (ITB4201) Example of mapping a weak entity
  • 18. Department of Information Technology 18Data base Technologies (ITB4201) Looks like this using relational schema notation
  • 19. Department of Information Technology 19Data base Technologies (ITB4201) Transforming E-R diagrams into relations Mapping binary relationships – One-to-many - primary key on the one side becomes a foreign key on the many side – Many-to-many - create a new relation (associative entity) with the primary keys of the two entities as its primary key • I like to call these intersection entities to distinguish them from associative entities created at the conceptual level – One-to-one - primary key on the mandatory side becomes a foreign key on the optional side
  • 20. Department of Information Technology 20Data base Technologies (ITB4201) Example of mapping a 1:M relationship
  • 21. Department of Information Technology 21Data base Technologies (ITB4201) Looks like this using relational schema notation
  • 22. Department of Information Technology 22Data base Technologies (ITB4201) Example of mapping an M:M relationship
  • 23. Department of Information Technology 23Data base Technologies (ITB4201) Looks like this using relational schema notation
  • 24. Department of Information Technology 24Data base Technologies (ITB4201) Mapping a binary 1:1 relationship
  • 25. Department of Information Technology 25Data base Technologies (ITB4201) Looks like this using relational schema notation
  • 26. Department of Information Technology 26Data base Technologies (ITB4201) Transforming E-R diagrams into relations Mapping associative entities – Identifier not assigned • Default primary key for the association relation is the primary keys of the two entities – Identifier assigned • It is natural and familiar to end-users • Default identifier may not be unique
  • 27. Department of Information Technology 27Data base Technologies (ITB4201) Mapping an associative entity with an identifier
  • 28. Department of Information Technology 28Data base Technologies (ITB4201) Looks like this using relational schema notation
  • 29. Department of Information Technology 29Data base Technologies (ITB4201) Transforming E-R diagrams into relations Mapping unary relationships – One-to-many - recursive foreign key in the same relation – Many-to-many - two relations: • One for the entity type • One for an associative relation in which the primary key has two attributes, both taken from the primary key of the entity
  • 30. Department of Information Technology 30Data base Technologies (ITB4201) For example... EMPLOYEE SupervisesEmp-Name Emp_Address Emp_Num
  • 31. Department of Information Technology 31Data base Technologies (ITB4201) Would look like... Emp_Num Emp_Name Emp_Address Boss_Num references
  • 32. Department of Information Technology 32Data base Technologies (ITB4201) And.. COMPONENT BOMDescription Unit_of-Measure Comp_Num Num_Units
  • 33. Department of Information Technology 33Data base Technologies (ITB4201) Would look like... Comp_Num Desc Unit_of_Measure COMPONENT Num-of_Units Comp_Num Subassembly_Num BOM
  • 34. Department of Information Technology 34Data base Technologies (ITB4201) Transforming E-R diagrams into relations Mapping ternary (and n-ary) relationships –One relation for each entity and one for the associative entity
  • 35. Department of Information Technology 35Data base Technologies (ITB4201) Mapping a ternary relationship
  • 36. Department of Information Technology 36Data base Technologies (ITB4201) Looks like this using relational schema notation
  • 37. Department of Information Technology 37Data base Technologies (ITB4201) Transforming E-R diagrams into relations Mapping Supertype/subtype relationships –Create a separate relation for the supertype and each of the subtypes –Assign common attributes to supertype –Assign primary key and unique attributes to each subtype –Assign an attribute of the supertype to act as subtype discriminator
  • 38. Department of Information Technology 38Data base Technologies (ITB4201) Mapping Supertype/subtype relationships
  • 39. Department of Information Technology 39Data base Technologies (ITB4201) Would look like this...
  • 40. Department of Information Technology 40Data base Technologies (ITB4201) Test Yourself 1. In a relational database a referential integrity constraint can be specified with the help of: a) primary key b) foreign key c) secondary key d) none of the above 1. Which of the following is not a feature of a god relational design? a) Specifying primary keys b) Specifying foreign keys c) Preserving integrity constraints d) Allowing redundancy of attributes 2. The dependency rules specified by the database designer is known as: a) Designer dependencies b) Database rules c) Functional dependencies d) None of the mentioned 1. Address field of a person should not be part of primary key, since it is likely to be: a) Dependent b) Too Long c) Changed d) Not Changed 5. A table is a collection of relationships, there is a close correspondence between concept of: a) Tables and instances b) Tables and variables c) Tables and relations d) Tables and entities
  • 41. Department of Information Technology 41Data base Technologies (ITB4201) Answers 1. In a relational database a referential integrity constraint can be specified with the help of: a) primary key b) foreign key c) secondary key d) none of the above 1. Which of the following is not a feature of a god relational design? a) Specifying primary keys b) Specifying foreign keys c) Preserving integrity constraints d) Allowing redundancy of attributes 2. The dependency rules specified by the database designer is known as: a) Designer dependencies b) Database rules c) Functional dependencies d) None of the mentioned 1. Address field of a person should not be part of primary key, since it is likely to be: a) Dependent b) Too Long c) Changed d) Not Changed 5. A table is a collection of relationships, there is a close correspondence between concept of: a) Tables and instances b) Tables and variables c) Tables and relations d) Tables and entities