DBMS Module 2 Part1
DBMS Module 2 Part1
PART 1
SYLLABUS
• Structure of Relational Databases - Integrity
Constraints, Synthesizing ER diagram to
relational schema
• Introduction to Relational Algebra - select,
project, cartesian product operations, join -
Equi-join, natural join. Query examples
• Introduction to Structured Query Language
(SQL), Data Definition Language (DDL), Table
definitions and operations – CREATE, DROP,
ALTER, INSERT, DELETE, UPDATE.
Relational data model
• First introduced by Ted Codd in 1970.
• Represent model represents database as a
collection of relations.
• Relation is a table which has values and rows in
table is a collection of related data values
• Each row represents a real world entity & its
related values.
• Row in relational table is called a tuple, column
header is attribute and table is a relation
Attributes
Relation name
EMPLOYEE
EMP_NO Name Address Mobile number Age Salary
Referential-Integrity Constraints
• It is specified between 2 relations.
• States that foreign key must contain a null
value or a valid primary key value.
Displaying a relational database
schema and its constraints
• Each relation schema can be displayed as a row of
attribute names.
• The name of the relation is written above the attribute
names.
• The primary key attribute (or attributes) will be
underlined.
• A foreign key (referential integrity) constraint is
displayed as a directed arrow from the foreign key
attribute to the primary key attribute of referenced table.
Synthesizing ER diagram to
relational schema
• Step 1: Mapping of regular entity types.
• Step 2: Mapping of weak entity types
• Step 3: Mapping of binary 1:1 relationship type
• Step 4: Mapping of binary 1:N relationship type
• Step 5: Mapping of binary M:N relationship type
• Step 6: Mapping of multivalued attributes
• Step 7: Mapping of N-ary relationship types
Step 1: Mapping of regular entity types
• For each weak entity type (W), with owner type (E),
create a relation (R) and include all simple attributes of
W.
• In addition, include the primary key of E as the foreign
key of R.
• Primary key of R = Primary key of E + partial key of W.
Step 3: Mapping of binary 1:1 relationship
type
• 3 approaches:
1) Foreign key approach
2) Merged relation approach
3) Cross-reference approach