Relational Model

Download Report

Transcript Relational Model

Module 3:
The Relational Model
 Overview

Terminology

Relational Data Structure

Mathematical Relations

Database Relations

Relational Keys

Relational Integrity

When is a DBMS Relational ?
 Terminology

The relational model is based on the mathematical
concept of a relation ,witch is physically represented as
a table. Codd, a mathematician ,use terminology taken
from mathematics ,principally set theory and predicate
logic
 Relational Data Structure

Relation : A relation is a table with columns and rows.

Attribute: an attribute is a name column of a relation.

Domain: A Domain is the set of allowable values for one more
attributes.

Tuple :A tuple is a row of relation .

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

Relational database: A collection of normalized relations.
 Relational Data Structure

Relation : A relation is a table with columns and rows.

Attribute: an attribute is a name column of a relation.

Domain: A Domain is the set of allowable values for one more
attributes.

Tuple :A tuple is a row of relation .

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

Relational database: A collection of normalized relations.
 Mathematical Relations

To understand the true meaning of the term relation, we
have to review some concepts from mathematics.
Suppose that we have two sets D1 and D2 were
D1={2,4}and D2 ={1,3,5}. The Cartesian product of these
two sets, written D1 *D2,is the set of all ordered pairs
such that the first element is a member of D2.

D1 *D2={(2,1),(2,3),(2,5),(4,1),(4,5)}

R= {(2,1),(4,1)}
 Database Relation

Relation Schema


A relation name followed by a set of attribute and
domain name Pairs.
Let A1,A2,A3…….An be attributes with domain
D1,D2,D3……Dn then the
set{A1:D1,A2:D2…….An:Dn} is a relational schema.
 Properties of Relations


The relation name has a name that is distinct from all other
relation.
Each cell of the relation contains exactly one atomic (single)
value.

Each attribute has a distinct name.

The values of an attribute are all from the same domain.

The order of attributes has no significance

Each tuple is distinct ; there are no duplicate tuples .

The order of tuples has no significance, theoretically. however
,in practice, the order may affect the efficiency of accessing
tuples .)
 Relational keys:


Primary key : The candidate key that is selected to
identify tuples uniquely within the relation.
Foreign key: Attribute or set of attributes within one
relation that matches the candidate key of some
(possibly the same ).relation .
 Relation Integrity




Nulls: Represented a value for an attribute that is currently
unknown not applicable for this tuple
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 value of tuple in its home relation
or the foreign key value must be wholly null .
Enterprise constrains
Additional rules specified by the user or database
administrator traitors of a database
 Relation Integrity





1-Foundational Rules
Rules( 0 and 12)
2-Structural Rules
Rules(1 and 6)
3- Integrity Rules
Rules(3 and 10)
4- Data Manipulation Rules
Rules(2,4,5 and 7)
5- Data Independence Rules
Rules(8,9,11)
Foundational Rules


Rules 0 – Foundational rule
For any system that is advertised as, or claimed to
be relation database management system , that
system must be able to manage database entirely
through its relational capabilities
Rule 12 – Non Subversion rule
If re a relational system has a low –level (single –
record-at-a-time) language ,that low level cannot be
used to subvert or bypass the integrity rule and
constraints expressed in the higher-level relational
language .
Structural Rules



Rule 1 – Information Representation
All information in a relational database is
represented explicitly at the logical level and in
exactly one exactly one way –by values in tables.
Rule -6 View Updating
All view that theoretically updateable are update
table by the system
Integrity Rules



Rule 3- Systematic of null values
Null values (distinct from the empty character
string or a string of blank Characters and distance
from zero or any other number )are supported for
representing missing information and in applicable
information in systematic way ,independent of data
type
Rule 10 – Integrity Independence
Integrity constraints specific to a particular relation
database must be definable in the relation data
sublanguage and storable in the catalog, not in the
application programs.
Data Manipulation Rules



Rule 2 – Guaranteed access
Each and every datum (atomic value) in a relational data base
is granted to be logically accessible by resorting to a
combination of table name primary key value and column
name
Rule 5 -Comprehensive data sublanguage
A relation system may support server language and various
models of terminal use .however there must be at least one
language whose statements can express all of the following
items (1)data definition (2)view definition (3)data manipulation
(4)integrity constrictions (5) authorization (6)transaction
boundaries
Rule 7 High level insert update delete
The capability of handling a base relation or derived relation
as a single operand applies not only the retrieval of data but
also to the insertion,update and deletion of data
Data Independence Rules



Rule 8 Physical data independent
Application program and terminal actives remain logical
unimpaired whenever any changes are made in either strong
representations or access methods
Rule 9 Logical data independence
Application program and terminal activities remain logically
unimpaired when information- preserving changes of any kind that
theoretically permit un impairment are made to the base table
Rule 11- Distribution independence
The data manipulation sublanguage of a relational DBMS must
enable application program and inquiries to remain logically the
same whether and whenever data are physically centralized or
distributed .