Chapter Three (2)
Chapter Three (2)
CHAPTER THREE
RELATIONAL DATABASE MODEL
3. Relational Database Model
This model is the most widely used. It was
Developed by Dr. Edgar Frank Codd in 1970 (famous paper, 'A Relational Model for
Large Shared Data Banks')
Originated from the branch of mathematics called set theory and relation
Intended for more flexible and complex relationship
Viewed as a collection of tables called “Relations” equivalent to collection of record
types having the following properties.
Relation: Two dimensional table
Stores information or data in the form of tables rows and columns
A row of the table is called tuple equivalent to record
A column of a table is called attribute equivalent to fields
Data value is the value of the Attribute
Records are related by the data stored jointly in the fields of records in two tables
or files. The related tables contain information that creates the relation
The tables seem to be independent but are related.
No physical consideration of the storage is required by the user
Many tables are merged together to come up with a new virtual view of the
relationship
Alternative terminologies
Relation Table File
Tuple RowRecord
AttributeColumnField
The rows represent records (collections of information about separate items)
The columns represent fields (particular attributes of a record)
Conducts searches by using data in specified columns of one table to find additional data
in another table
In conducting searches, a relational database matches information from a field in one
table with information in a corresponding field of another table to produce a third table
that combines requested data from both tables
Building Blocks of the Relational Data Model
The building blocks of the relational data model are:
1. Entities: real world physical or logical object
2. Attributes: properties used to describe each Entity or real world object.
3. Relationship: the association between Entities
4. Constraints: rules that should be obeyed while manipulating the data.
1. The ENTITIES (persons, places, things etc.) which the organization has to deal with.
Relations can also describe relationships.
Entity sets - An entity is a thing or an object in the real world that is distinguishable from
all other objects - An entity may be concrete (a person or a book, for example) or abstract
(like or a concept like Account in a bank) - An entity set is a set of entities of the same
type (share the same properties/attributes)
Example of entity:
Person – employee, student, patient
1|Page
Chapter Three: Relational Database Model
2. The ATTRIBUTE the items of information which characterize and describe these
entities. Attributes are pieces of information ABOUT entities. The analysis must of
course identify those which are actually relevant to the proposed application. Attributes
will give rise to recorded items of data in the database At this level we need to know such
things as:
Attribute name (be explanatory words or phrases)
The domain from which attribute values are taken (A DOMAIN is a set of values
from which attribute values may be taken.) Each attribute has values taken from a
domain.
o For example, the domain of Name is string and that for salary is real
Whether the attribute is part of the entity identifier (attributes which just describe
an entity and those which help to identify it uniquely)
Whether it is permanent or time-varying (which attributes may change their
values over time)
Whether it is required or optional for the entity (whose values will sometimes
be unknown or irrelevant)
Types of Attributes
(1) Simple (atomic) Versus Composite attributes
Simple : contains a single value (not divided into sub parts) E.g. Age, gender
Composite: Divided into sub parts (composed of other attributes)
E.g. Name, address
(2) Single-valued versus multi-valued attributes
Single-valued : have only single value(the value may change but has only
one value at one time)
E.g. Name, Sex, Id. No. color_of_eyes
Multi-Valued: have more than one value
E.g. Address, dependent-name Person may have several college degrees
(3) Stored vs. Derived Attribute
Stored : not possible to derive or compute
E.g. Name, Address
2|Page
Chapter Three: Relational Database Model
Derived: The value may be derived (computed) from the values of other
attributes.
E.g. Age (current year – year of birth)
Length of employment (current date- start date)
Profit (earning-cost)
G.P.A (grade point/credit hours)
(4) Null Values
NULL applies to attributes which are not applicable or which do not have
values.
You may enter the value NA (meaning not applicable)
Value of a key attribute cannot be null.
Default value - assumed value if no explicit value
Entity versus Attributes
When designing the conceptual specification of the database, one should pay attention to the
distinction between an Entity and an Attribute.
Consider designing a database of employees for an organization:
Should address be an attribute of Employees or an entity (connected to Employees by a
relationship)?
If we have several addresses per employee, address must be an entity (attributes cannot be set-
valued/multi valued)
If the structure (city, Woreda, Kebele, etc) is important, e.g. want to retrieve employees in a
given city, address must be modeled as an entity (attribute values are atomic)
3. Relationship
The RELATIONSHIPS between entities which exist and must be taken into account when
processing information. In any business processing one object may be associated with
another object due to some event. Such kind of association is what we call a
RELATIONSHIP between entity objects.
One external event or process may affect several related entities.
Related entities require setting of LINKS from one part of the database to another.
A relationship should be named by a word or phrase/Roles which explains its
function
Role names are different from the names of entities forming the relationship: one
entity may take on many roles, the same role may be played by different entities
For each RELATIONSHIP, one can talk about the Number of Entities and the
Number of Tuples/rows participating in the association. These two concepts are
called DEGREE and CARDINALITY of a relationship respectively.
Degree of a Relationship
An important point about a relationship is how many entities participate in it. The
number of entities participating in a relationship is called the DEGREE of the
relationship.
3|Page
Chapter Three: Relational Database Model
ONE-TO-MANY, one tuple can be associated with many other tuples, but not the
reverse.
o E.g. Department-Student as one department can have multiple students.
MANY-TO-ONE, many tuples are associated with one tuple but not the reverse.
o E.g. Employee – Department: as many employees belong to a single department.
MANY-TO-MANY: one tuple is associated with many other tuples and from the other
side, with a different role name one tuple will be associated with many tuples
E.g. Student – Course
4|Page
Chapter Three: Relational Database Model
o As a student can take many courses and a single course can be attended by many
students.
5|Page
Chapter Three: Relational Database Model
Example:
6|Page
Chapter Three: Relational Database Model
7|Page
Chapter Three: Relational Database Model
8|Page
Chapter Three: Relational Database Model
9|Page
Chapter Three: Relational Database Model
10 | P a g e
Chapter Three: Relational Database Model
11 | P a g e
Chapter Three: Relational Database Model
That is one for each of the two participating entities and the third for the associative entity. The
relation formed from the associative entity is associative relation.
With identifier
Sometimes data model assigns an identifier to the associative entity on the ER diagram. There
are two reasons to motivate this approach
the associative entity type has a natural identifier that is familiar to end user
the default identifier may not uniquely identify instance of the associative entity
Eg. Shipment number is a natural identifier to end user rather than having the default identifier
customer id and vendor id as an identifier for the associative entity called shipment
12 | P a g e
Chapter Three: Relational Database Model
13 | P a g e
Chapter Three: Relational Database Model
Generalization is the process of defining a more general entity type from a set of more
specialized entity types.
A generalization hierarchy is a form of abstraction that specifies that two or more entities
that share common attributes can be generalized into a higher level entity type.
Is considered as bottom-up definition of entities.
Generalization hierarchy depicts relationship between higher level superclass and lower
level subclass.
Generalization hierarchies can be nested. That is, a subtype of one hierarchy can be a
super type of another. The level of nesting is limited only by the constraint of simplicity.
Example: Account is a generalized form for Savings and Current Accounts
Example: the figure below shows the concept of generalization and specification.
Specialization
Is the result of subset of a higher level entity set to form a lower level entity set.
The specialized entities will have additional set of attributes (distinguishing
characteristics) that distinguish them from the generalized entity.
Is considered as Top-Down definition of entities.
Specialization process is the inverse of the Generalization process.
Identify the distinguishing features of some entity occurrences, and specialize them into
different subclasses.
Reasons for Specialization
o Attributes only partially applying to super classes
o Relationship types only partially applicable to the superclass
In many cases, an entity type has numerous sub-groupings of its entities that are
meaningful and need to be represented explicitly. This need requires the representation of
each subgroup in the ER model. The generalized entity is a superclass and the set of
specialized entities will be subclasses for that specific Superclass.
Example: Saving Accounts and Current Accounts are Specialized entities for the
generalized entity Accounts. Manager, Sales, Secretary: are specialized
employees.
14 | P a g e