0% found this document useful (0 votes)
10 views20 pages

Chapter Three

Uploaded by

Bali Bikila
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views20 pages

Chapter Three

Uploaded by

Bali Bikila
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Chapter Three

Relational Data Model


Aug/19

01/10/2024 1
Contents:
• Properties of Relational Database
• Key constraints
• Building Blocks of the Relational Data Model
• Relational Constraints/Integrity Rules
• Types of Attributes
• Participation constraint

01/10/2024 2
…con’t
Important terms:
• Relation: a table with rows and columns
• Attribute: a named column of a relation
• Domain: a set of allowable values for one or more attributes
• Tuple: a row of a relation
• Degree: the degree of a relation is the number of attributes it contains
• Unary relation, Binary relation, Ternary relation, N-nary relation
• Cardinality: of a relation is the number of tuples the relation has
• Relational Database: a collection of normalized relations with distinct
relation names.
01/10/2024 3
Properties of Relational Database
A relation has a name that is distinct from all other relation names in the
relational schema.
• Each 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
candidate key.
• Each cell of a relation contains exactly one atomic (single) value.
• Entity integrity rule of the model sates that no component of the
primary key may contain a null value.
01/10/2024 4
…con’t
• A column or combination of columns that matches the primary key of
another table is called 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.
•  Each column (field or attribute) has a distinct name.
•  The values of an attribute are all from the same domain.
• A table is either a BASE TABLES (Named Relations) or VIEWS
(Unnamed Relations)

01/10/2024 5
…con’t
• Only Base Tables are physically stored
• VIEWS are derived from BASE TABLES with SQL statements like:
[SELECT .. FROM .. WHERE .. ORDER BY]
• Relational database is the collection of tables
• Each entity in one table
• Attributes are fields (columns) in table
• Order of rows theoretically ( but practically has impact on
performance) and columns is immaterial
 All values in a column represent the same attribute and have the same
data format
01/10/2024 6
…con’t
Student table DB Exam table
Stud_Name Stud_Id Sex Age Dep’t Mark Stud_Id Section
Hamid Ali 01 M 24 Comp 15 02 1
Dereja Tujo 02 M 25 Comp 14 03 1
Bereket Bogale 03 M 23 Comp 14 04 1
Hiwot Tadese 04 F 22 Comp
Stud_Id----is the foreign key on DB exam table
Stud_Id---is the primary key in student table

 Therefore this two table are related by key attributes

01/10/2024 7
Key Constraints
• If tuples are need to be unique in the database, and then we need to
make each tuple distinct. To do this we need to have relational keys
that uniquely identify each record.
• 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.

01/10/2024 8
Building Blocks of the Relational Data Model
• The building blocks of the relational data model are:
 Entities: real world physical or logical object
 Attributes: properties used to describe each Entity or real world
object.
 Relationship: the association between Entities
 Constraints: rules that should be obeyed while manipulating the data

01/10/2024 9
…con’t
1. The ENTITIES (persons, places, things etc.) which the organization
has to deal with. Relations can also describe relationships
• 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
the relation itself corresponds to our familiar notion of a table:
• A relation is a collection of tuples, each of which contains values for
a fixed number of attributes

01/10/2024 10
…con’t

• Existence Dependency: the dependence of an entity on the existence


of one or more entities.
• Strong entity: is an entity which has an independent existence in the
database.
• Weak entity : an entity which existent dependent on strong entity. It
doesn't have a primary key.

01/10/2024 11
…con’t
2. The ATTRIBUTES - 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.
01/10/2024 12
…Con’t
• For example, domain of Name is string and that for salary is real. How
ever these are not shown on E-R models
• 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)

01/10/2024 13
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 assume a value of NULL
 Referential Integrity: If a Foreign Key exists in a relation, either
the Foreign Key value must match a Candidate Key value in its home
relation or the Foreign Key value must be NULL
 Enterprise Integrity: Additional rules specified by the users or
database administrators of a database are incorporated

01/10/2024 14
Types of Attributes
(1) 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
(2) 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.
Multi-Valued: have more than one value
E.g. Address, dependent-name
• Person may have several college degrees
01/10/2024 15
…con’t
(3) 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)

01/10/2024 16
…con’t

(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 can not be null.
• Default value - assumed value if no explicit value

01/10/2024 17
Participation Constraint
• Constraint means rules that must be obeyed or followed
• There are two ways an entity can participate in a relationship, thus are:
1. Total (Mandatory participation)
2. Partial (optional participation)
• The participation is total(mandatory) if an entities existence requires
the existence of an associated entity in a relationship. But if it doesn’t
requires it is known as optional.

01/10/2024 18
…con’t
Example:
• If the business rule of an organization allows a single employee of the
organization as aright to take two course as a capacity building activity
and also it is possible that the individuals has a right not to take any
course therefor course is an optional to the employee but employee is
a mandatory.

01/10/2024 19
-End-

01/10/2024 20

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy