0% found this document useful (0 votes)
17 views22 pages

Unit 1 Mapping Constraints

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views22 pages

Unit 1 Mapping Constraints

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

School of Computing

Science and Engineering

Program: B.TECH
Course Code:E2UC302B
Course Name: Database Management
System
School of Computing Science and Engineering
Course Code :E2UC302B Course Name: DBMS
Vision
To be known globally as a premier department of Computer
Science and Engineering for value-based education,
multidisciplinary research and innovation.

Mission
 M1: Developing a strong foundation in fundamentals of
computing science with responsiveness towards emerging
technologies.
 M2: Establishing state-of-the-art facilities and adopt education
4.0 practices to analyze, develop, test and deploy sustainable
ethical IT solutions by involving multiple stakeholders.
 M3: Establishing Centers of Excellence for multidisciplinary
collaborative research in association with industry and
academia.
Program Name: B.TECH Program Code: E2UC302B
School of Computing Science and Engineering
Course Code :E2UC302B Course Name: DBMS

Course Outcomes (COs)


CO Number Title
Conceptual understanding of DBMS, ability to define and
manipulate data, understanding data independence, and the
CO1 overall structure of databases.

Ability to design and query relational databases using SQL,


ensure data integrity, and apply relational algebra and calculus
CO2 concepts in practical scenarios.

Apply database Normalization techniques up to BCNF for the


CO3 removal of anomalies.

Ability to manage and ensure the consistency of transactions,


implement concurrency control mechanisms, recover from
CO4 transaction failures.

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code : BSCS2312 Course Name: DBMS

Course Prerequisites
 Knowledge of Mathematics
 Query Languages

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code :E2UC302B Course Name: DBMS
Syllabus
Unit 2 – ER Modeling & SQL (10 hours)
 ER Model Concepts, Notation for ER diagram
 Mapping Constraints
 Keys, Concepts of Super Key, Candidate Key, Primary Key
 Generalization- Aggregation
 Reduction of an ER Diagrams to Tables, Extended ER Model

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code :E2UC302B Course Name: DBMS
Recommended Books
Text books
 Abraham Silberschatz, Henry F. Korth and S. Sudarshan- “Database System
Concepts”, Fourth Edition, McGraw-Hill, 2002.
Reference Book
 Ramez Elmasri and Shamkant B. Navathe, “Fundamental Database Systems”,
Third Edition, Pearson Education, 2003.
 Raghu Ramakrishnan, “Database Management System”, Tata McGraw- Hill
Publishing Company, 2003.
 Hector Garcia–Molina, Jeffrey D.Ullman and Jennifer Widom- “Database System
Implementation”- Pearson Education- 2000
 Peter Rob and Corlos Coronel- “Database System, Design, Implementation and
Management”, Thompson Learning Course Technology- Fifth edition, 2003
Additional online materials
 Coursera - https://www.coursera.org/learn/database-management
 NPTEL- https://nptel.ac.in/courses/106/105/106105175/
 https://www.coursera.org/learn/research-methods
 https://www.coursera.org/browse/physical-science-and-engineering/research-
methods
Program Name: B.TECH Program Code: E2UC302B
School of Computing Science and Engineering
Course Code :E2UC302B Course Name: DBMS
Mapping Constraints
 A mapping constraint is a data constraint that expresses the number of
entities to which another entity can be related via a relationship set.
 It is most useful in describing the relationship sets that involve more than
two entity sets.
 For binary relationship set R on an entity set A and B, there are four
possible mapping cardinalities. These are as follows:
 One to one (1:1)
 One to many (1:N) and Many to one (N:1)
 Many to many (N:M)

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code :E2UC302B Course Name: DBMS
Cardinality of Relationship
 It is the number of instances in one entity which is associated to the number
of instances in another.
 For the relationship between Employee and Computer, it helps us answer
questions like how many computers can be allocated to an employee, can
computers be shared between employees, can employees exist without
being allocated a computer etc.
 Three types: 1:1, 1:N and M:N.

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code :E2UC302B Course Name: DBMS
Crow Foot Notation
 It is one of the ways to represent cardinality of relationship in an ER
Model.
 The notation comprises of four symbols and one of them need to be used
for each entity in a relationship.

 Computer must be allocated to one and only one employee but an employee
can be allocated zero or any number of computers.

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code :E2UC302B Course Name: DBMS
Data Integrity Constraints
 Maintaining and assuring the accuracy and consistency of data.
 Three types of integrity constraints:

Integrity Enforced
Types Definition Through
Entity Each table must have a column or a set of columns Primary
Integrity through which we can uniquely identify a row. Key
These column(s) cannot have empty (null) values.
Domain All attributes in a table must have a defined Data Types,
Integrity domain. In addition we can also have value Check
restriction as per business rules e.g. Gender must be Constraint
M or F.
Referential Every value of a column in a table must exist as a Foreign Key
Integrity value of another column in a different (or the same)
table.

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code : E2UC302B Course Name: DBMS

Data Integrity Constraints

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code : E2UC302B Course Name: DBMS

Candidate Key
 Minimal set of columns/attributes that can be used to uniquely identify a
single tuple in a relation.
 Candidate Keys are determined during database design based on the
underlying business rules of the database.
 Employee(EmployeeNo, Name, AadharNo, Salary, DateOfBirth)

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code : E2UC302B Course Name: DBMS

Candidate Key
Key Rationale
EmployeeNo This seems to be a good candidate key as companies usually issue a
unique number for each employee.
AadharNo This seems to be a good candidate key for a company based in India.
However we have assumed that every employee has an Aadhar
number which may not be true. In addition for a multinational firm
with employees across the globe this will not work at all.
Name, This might work for a small firm of 10 people as a combination of
DateOfBirth Name and Date of Birth is likely to be unique.
Salary This is not a good candidate as salary is generally paid uniformly to
people at same level.
EmployeeNo, It is not a candidate key as EmployeeNo alone is unique. By definition
DateOfBirth only minimal set of attributes can be candidate key.

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code : E2UC302B Course Name: DBMS
Primary Key
 It is the candidate key that is selected to uniquely identify a tuple in a
relation.

Mandatory Desired
Must uniquely identify a tuple Should not change with time
Must not allow NULL values Should have short size e.g. numeric
data types

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code : E2UC302B Course Name: DBMS

Foreign Key
 It is a set of one or more columns in the child table whose values are
required to match with corresponding columns in the parent table.
 Foreign key columns on child tables must be primary key or unique on
the parent table.
 The child table can contain NULL values. Let us take Employee and
Computer tables as provided below:

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code : E2UC302B Course Name: DBMS

Converting ER Models to Relational Tables


1:1 Relationship
 It represents association between single occurrence of one entity and a
single occurrence of the second entity.
 For e.g. consider a company where each employee can be allocated a
maximum of 1 computer and computers are not shared between employees.
 Allot_Dt which is the attribute of the relationship is always stored in the
table that has the foreign key.
 Alternatively we could also have added Id and Allot_Dt attributes.

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code : E2UC302B Course Name: DBMS

Converting ER Models to Relational Tables


1:M Relationship
 It represents association between single occurrence of one entity and
multiple occurrences of second entity.
 For e.g. consider a company where each employee can be allocated many
computers but still computers cannot be shared between employees.
 The foreign key and relationship attributes are always added to the many
(N) side of the relationship.

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code : E2UC302B Course Name: DBMS

Converting ER Models to Relational Tables


M:N Relationship
 It represents association between multiple occurrence of both entities.
 For e.g. consider a company where each employee can be allocated many
computers and computers can be shared between employees.
 the relationship is represented by a completely new table that has a
composite primary key.
 The attribute of the relationship resides on this new table.

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code : E2UC302B Course Name: DBMS

Converting ER Models to Relational Tables


Strong Entity Set With Only Simple Attributes
 A strong entity set with only simple attributes will require only one table in
relational model.
 Attributes of the table will be the attributes of the entity set.
 The primary key of the table will be the key attribute of the entity set.

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code : E2UC302B Course Name: DBMS

Converting ER Models to Relational Tables


Strong Entity Set With Composite Attributes
 A strong entity set with any number of composite attributes will require
only one table in relational model.
 While conversion, simple attributes of the composite attributes are taken
into account and not the composite attribute itself.

Program Name: B.TECH Program Code: E2UC302B


School of Computing Science and Engineering
Course Code : E2UC302B Course Name: DBMS

Converting ER Models to Relational Tables


Strong Entity Set With Multivalued Attributes
 A strong entity set with any number of multi valued attributes will require
two tables in relational model.
 One table will contain all the simple attributes with the primary key.
 Other table will contain the primary key and all the multi valued attributes.

Program Name: B.TECH Program Code: E2UC302B

You might also like