0% found this document useful (0 votes)
7 views

Chapter 2

this is advance DBS

Uploaded by

Tseagaye Biresaw
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Chapter 2

this is advance DBS

Uploaded by

Tseagaye Biresaw
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Chapter 2: Relational Data Model

 Relational data model is the primary data model,


which is used widely around the world for data storage
and processing.
 This model is simple and it has all the properties and
capabilities required to process data with storage
efficiency.
 The relational data model provides conceptual tools
to design the database schema of the relational
database.
 The relational model describes the data, relationship
between that data, data sematic and constraints on the
data in the relational database.
Prepared by: Elsaye B. @WSU-DTC 1
Properties of Relational Databases
Each row of a table is uniquely identified by a PRIMARY
KEY composed of one or more columns
Each tuple in a relation must be unique
Group of columns, that uniquely identifies a row in a table is
called a CANDIDATE KEY
ENTITY INTEGRITY RULE of the model states that no
component of the primary key may contain a NULL value.
A column or combination of columns that matches the
primary key of another table is called a FOREIGN KEY.
Used to cross-reference tables.
The REFERENTIAL INTEGRITY RULE of the model
states that, for every foreign key value in a table there must be
a corresponding primary key value in another table in the
database or it should be NULL.
Prepared by: Elsaye B. @WSU-DTC 2
Cont..
 All tables are LOGICAL ENTITIES
 A table is either a BASE TABLES (Named Relations) or
VIEWS (Unnamed Relations)
 Only Base Tables are physically stores
 VIEWS are derived from BASE TABLES with SQL
instructions like: [SELECT .. FROM .. WHERE .. ORDER
BY]
 Is the collection of tables
 Each entity in one table
 Attributes are fields (columns) in table
 Order of rows and columns is immaterial
 Entries with repeating groups are said to be un-normalized
 Entries are single-valued
Prepared by: Elsaye B. @WSU-DTC 3
 Each column (field or attribute) has a distinct name
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.

Prepared by: Elsaye B. @WSU-DTC 4


Cont..
1. The ENTITIES (persons, places, things etc.)
The name given to an entity should always be
a singular noun descriptive of each item to be
stored in it. E.g.: student NOT students.
Every relation has a schema, which describes
the columns, or fields
A relation is a collection of tuples, each of
which contains values for a fixed number
of attributes
Prepared by: Elsaye B. @WSU-DTC 5
Cont..
2. The ATTRIBUTES - the items of information which
characterize and describe these entities.
 Attributes are pieces of information ABOUT entities.
 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.)
 Whether the attribute is part of the entity identifier
 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 beby:unknown
Prepared Elsaye B. @WSU-DTC or irrelevant) 6
Types of Attributes
A. Simple (atomic) Vs 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
B. Single-valued Vs 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
Prepared by: Elsaye B. @WSU-DTC 7
Cont..
C. Stored vs. Derived Attribute
 Stored : not possible to derive or compute
E.g. Name, Address
 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)
D. 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 can not be null.
 Default value - assumedPrepared
valueby:if noB. @WSU-DTC
Elsaye explicit value 8
Cont..
3. The RELATIONSHIPS between entities which exist and
must be taken into account when processing information.
 One external event or process may affect several related
entities.
 Related entities require setting of LINKS from one part of
the database to another.
 The number of entities participating in a
relationship is called the DEGREE of the relationship.
 UNARY/RECURSIVE RELATIONSHIP: Single entity
 BINARY RELATIONSHIPS: Two entities associated
 TERNARY RELATIONSHIP: Three entities associated
 N-NARY RELATIONSHIP: arbitrary number of entity sets

Prepared by: Elsaye B. @WSU-DTC 9


Cont..
 The number of instances participating or associated
with a single instance from another entity in a
relationship is called the CARDINALITY of the
relationship.
ƒ ONE-TO-ONE, e.g. Building - Location,
ƒ ONE-TO-MANY, e.g. hospital - patient,
ƒ MANY-TO-ONE, e.g. Employee - Department
ƒ MANY-TO-MANY, e.g. Author - Book.

Prepared by: Elsaye B. @WSU-DTC 10


Cont..
4. Relational Constraints/Integrity Rules
Relational Integrity
Domain Integrity: No value of the attribute should be
beyond the allowable limits
Entity Integrity: In a base relation, no attribute of a
primary key can be null
Referential Integrity: If a foreign key exists in a
relation, either the foreign key value must match a
candidate key in its home relation or the foreign key
value must be null foreign key to primary key
match-ups
Enterprise Integrity: Additional rules specified by the
users or database administrators of a database are
incorporated Prepared by: Elsaye B. @WSU-DTC 11
Cont...

 Key constraints
 Super Key: an attribute or set of attributes that uniquely identifies a
tuple within a relation.
 Candidate Key: a super key such that no proper subset of that
collection is a Super Key within the relation.
 A candidate key has two properties:
1. Uniqueness
2. Irreducibility
 If a candidate key consists of more than one attribute it is called
composite key.
 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 relation.
 A foreign key is a link between different relations to create the view
or the unnamed relation Prepared by: Elsaye B. @WSU-DTC 12
Cont..

Referential constraints
 A referential integrity constraint is also known as
foreign key constraint. A foreign key is a key whose
values are derived from the Primary key of another
table.
 The table from which the values are derived is known as
Master or Referenced Table and the Table in which
values are inserted accordingly is known as Child or
Referencing Table,
 In other words, we can say that the table containing the
foreign key is called the child table, and the table
containing the Primary key/candidate key is called the
referenced or parent table.
Prepared by: Elsaye B. @WSU-DTC 13
Cont..
There are three referential integrity constraint:
 Insert Constraint: Value cannot be inserted in
CHILD Table if the value is not lying in
MASTER Table
 Delete Constraint: Value cannot be deleted
from MASTER Table if the value is lying in
CHILD Table
 UPDATE Constraint: Value cannot be
modified in CHILD Table if the value is not
lying in MASTER Table.
Prepared by: Elsaye B. @WSU-DTC 14

You might also like