Professional Documents
Culture Documents
Chapter 3 Database Modeling
Chapter 3 Database Modeling
Chapter 3 Database Modeling
DATABASE SYSTEMS
Chapter 3
The Relational Data
Model and Relational
Database Constraints
Chapter Outline
The Relational Data Model and
Relational Database Constraints
Relational Model Constraints
and Relational Database Schemas
Update Operations, Transactions,
and Dealing with Constraint Violations
Relational Model Concepts
The relational Model of Data is based on the concept of a
Relation.
A Relation is a mathematical concept based on the ideas of sets.
Figure 3.2B Domains for some attributes of the Branch and Staff relations.
Formal Definitions
Degree: The degree of a relation is the number of attributes it
contains.
Cardinality :The cardinality of a relation is the number of
tuples it contains.
Formally,
Let S1 = {0,1}
Let S2 = {a,b,c}
Let R S1 X S2
Table Relation
Column Attribute/Domain
Row Tuple
Values in a column Domain
Table Definition Schema of a Relation
Populated Table Extension
Example - Figure 3.1
Characteristics Of Relations
Ordering of tuples in a relation r(R):
Uppercase letters Q, R, S
Denote relation names
Lowercase letters q, r, s
Denote relation states
Letters t, u, v
Denote tuples
Relational Model Notation
Name of a relation schema: STUDENT
Indicates the current set of tuples in that relation
Notation: STUDENT(Name, Ssn, ...)
Refers only to relation schema
Attribute A can be qualified with the relation name
R to which it belongs
Using the dot notation R.A
Relational Model Notation
n-tuple t in a relation r(R)
t[Au, Aw, ..., Az] and t.(Au, Aw, ..., Az) refer to the subtuple of
The relation has a name that is distinct from all other relation names in
the relational schema;
Each cell of the relation contains exactly one atomic (single) value;
Key constraints
Key of R:
A "minimal" super key; that is, a super key K such that removal of any
attribute from K results in a set of attributes that is not a super key.
Key Constraints
Example: The CAR relation schema:
has two keys Key1 = {State, Reg#}, Key2 = {SerialNo}, which are also
super keys. {SerialNo, Make} is a super key but not a key.
If a relation has several candidate keys, one is chosen arbitrarily to be the
primary key.
The primary key attributes are underlined.
Primary key: The candidate key that is selected to identify tuples uniquely
within the relation.
Foreign key : An attribute, or set of attributes, within one relation that
matches the candidate key of some (possibly the same) relation.
Key Constraints
Candidate key: A superkey such that no proper subset is a superkey within the relation.
A candidate key, K, for a relation R has two properties:
uniqueness– in each tuple of R, the values of K uniquely identify that tuple;
Client (clientNo,fName,lName,telNo,prefType,maxRent)
PrivateOwner (ownerNo, fName,lName,address,telNo)
Viewing (clientNo, propertyNo,viewDate,comment)
Registration (clientNo, branchNo,staffNo,dateJoined)
Examples
Design a relational database for a company
registrar’s office. The office maintains data about
each work, including the company, the managers,
the number of employee , and the place/locations
of the company.
Answers
Employee(person-name,street,city)
works(person-name,company-name,salary)
Company(company-name,city)
Manages(person-name,manager-name)
Entity Integrity
Entity Integrity:
E.g., “the max. no. of hours per employee for all projects he or
she works on is 56 hrs per week”
DELETE a tuple.
MODIFY a tuple.
STANDARD PROCEDURES:
3.1 Analyzing the Problem:
According to above problem statement, name the relation by
identifying the noun and the associating relation (Relationship set) by
identifying the verb.
Here, Customer s and Salesmen are noun so they are considered as
Entity and Order is verb so it is considered as Relationship.
After assigning the name of the relation, identify the attributes for each of
the relations. Also identify the primary key for each of the relation.
Then draw E-R diagram.