Departmen Computer
CSE Science
t of &Engineering
Logical Database Design
and the Relational Model - I
Lecture 07
CSC 401: Database Management
System
Basic Definitions
⚫ Data structure Data are organized in the form of
tables, with rows and columns.
⚫ Data manipulation Powerful operations (using the
SQL language) are used to manipulate data stored
in the relations.
⚫ Data integrity The model includes mechanisms to
specify business rules that maintain the integrity of
data when they are manipulated.
Departmen Computer
CSE Science
t of &Engineering CSC 401: database Management
System
Database
RELATIONAL DATA STRUCTURE
⚫ Relation A named two-dimensional table of data.
⚫ Primary key An attribute or a combination of attributes
that uniquely identifies each row in a relation.
⚫ Composite key A primary key that consists of more
than one attribute.
⚫ Foreign key An attribute in a relation that serves as the
primary key of another relation in the same database.
Departmen Computer
CSE Science
t of &Engineering CSC 401: database Management
System
Database
PROPERTIES OF RELATIONS
⚫ Each relation (or table) in a database has a unique
name.
⚫ An entry at the intersection of each row and column is
atomic, i.e, no multivalued attributes are allowed in a
relation.
⚫ Each row is unique.
⚫ Each attribute (or column) within a table has a unique
name.
⚫ The sequence of columns (left to right) is insignificant.
⚫ The sequence of rows (top to bottom) is insignificant.
Departmen Computer
CSE Science
t of &Engineering CSC 401: database Management
System
Database
Eliminating multi-valued attributes
Departmen Computer
CSE Science
t of &Engineering CSC 401: database Management
System
Database
INTEGRITY CONSTRAINTS
⚫ Domain Constraints All of the values that appear in a column
of a relation must be from the same domain.
⚫ Entity Integrity The entity integrity rule is designed to ensure
that every relation has a primary key and that the data values
for that primary key are all valid.
⚫ Null A value that may be assigned to an attribute when no other
value applies or when the applicable value is unknown.
⚫ Entity integrity rule A rule that states that no primary key
attribute (or component of a primary key attribute) may be
null.
Departmen Computer
CSE Science
t of &Engineering CSC 401: database Management
System
Database
INTEGRITY CONSTRAINTS
⚫ Referential integrity constraint A rule that states that either
each foreign key value must match a primary key value in
another relation or the foreign key value must be null.
⚫ Whether a foreign key can be null is more complex to model
on an E-R diagram. For example, what happens to order
data if we choose to delete a customer who has submitted
orders?
⚫ Cascade: Delete the associated orders.
⚫ Restrict: Prohibit deletion of the customer until all associated
orders are first deleted
⚫ Set-to-Null: Place a null value in the foreign key
Departmen Computer
CSE Science
t of &Engineering CSC 401: database Management
System
Database
Referential integrity constraints (Pine Valley
Furniture)
Referential
integrity
constraints are
drawn via arrows
from dependent to
parent table
Well-structured relation
⚫ A relation that contains minimal redundancy and
allows users to insert, modify, and delete the rows in
a table without errors or inconsistencies.
⚫ Anomaly An error or inconsistency that may result
when a user attempts to update a table that contains
redundant data. The three types of anomalies are
insertion, deletion, and modification anomalies.
⚫ Insertion anomaly
⚫ Deletion anomaly
⚫ Modification anomaly
Departmen Computer
CSE Science
t of &Engineering CSC 401: database Management
System
Database
Step01: Mapping the regular entity CUSTOMER
Step01: Mapping a composite attribute
Step01: Mapping an entity with a multivalued attribute
Step 2: Mapping a weak entity
Step 3: Mapping a Binary 1:M relationship
Step 3: Mapping a M:N relationship
Step 3: Mapping a binary 1:1
CSC 401: database Management
System
Step 4: Map Associative Entities
Step 4: Map Associative Entities
Step 5: Map Unary Relationships
Step 5: Mapping a unary M:N relationship
CSC 401: database Management
System
Step 6: Mapping a ternary relationship
CSC 401: database Management
System
Step 7: Map Supertype/Subtype Relationships
CSC 401: database Management
System
Relation Rules
1. All the entities (Strong, Weak, Associative,
SubType, SuperType) will be relation
2. Many to Many relationships will be converted to a
Relation.
3. Multi-valued Attributes will be converted to
Relation.
Departmen Computer
CSE Science
t of &Engineering Database
Relational Integrity
1. 1 - Many: One side pk moves to many side and foreign key.
2. 1 - 1: Mandatory side pk moves to optional side as foreign
key.
3. Many to Many: Both side pk comes to the new relaton as
fks. If pk not exist fk become pk.
4. SuperType-SubType: Supertype’s pk moves to Subtype as
fk later converted to pk with discriminator prefix.
5. Multi-values attribute will become a relation and
combination of the attribute and the pk of the main
relation will be the pk of the new relation.
Departmen Computer
CSE Science
t of &Engineering Database
Thank You
Departmen Computer
CSE Science
t of &Engineering CSC 401: database Management
System
Database