Вы находитесь на странице: 1из 34

m 

- A database model based on first-order predicate logic


(mathematics, U-union, ^ - conjunction, V -
disjunction), first formulated and proposed in late 1960s
by Edgar Frank DzTeddz Codd (1923-2003) (wikipedia).
- The underlying basis for relational model is the concept
of mathematical relation (which will be discussed later)
- The standard database model for most transaction
database today
- Relational model for database management is the
theoretical basis for relational databases.
ï 
   

- A relational database is a collection of relation.


- A relation resembles a table or a Dzflat filedz of records.
- Each row in such a table represents a collection of such
related data values (an Dzinstancedz of the relation depicted
by the table).
- Each row or a relation instance is called a tuple and each
column is called attribute of the relation.
Student
      ï 



2010-01 Angelo Macha 05-31-2010

2010-02 Gringo Maquinay 06-05-2010

2010-03 Willy Concha 06-06-2010


  



- A data value is said to be Dz 
dz if it cannot be
subdivided into smaller parts. (e.g. the age of a person in
years is an atomic value.)
- A Dzdomaindz is a set of atomic values or set of permitted
values of the attributes.
- A Dzrelation schemadz denoted by R(A1, A2, A3,ǥ, An) is
made up of relation name R and a list of attributes A1, A2,
A3ǥ. An. Each An is the name of attribute by some
domain in the schema R. The domain A1 is denoted by
dom(A1).
 




- The Dzdegreedz of the relation is the number of attributes of
its relation schema.
- A relation is a tuple (£, ) with £, the header, and , the
body, a set of tuples that all have the domain £.
   

 ï 

- Tuples are unordered.
- Attributes are unordered.
- Values of tuples are atomic.
- A relation has zero or more tuples.
ï 
 

- Domain Constraints.
- Key Contraints.
- Superkey
- Set of one or more attributes than, taken
collectively, allow us to identify uniquely a tuple in
relation.
- A superkey K holds in relation(H,B) if:
- K Ñ H and
- There exist no two distinct tuples t1, t2 B
such that t1[K] ό t2[K].
ï 
 

- Candidate Key Ȃ a subset of superkey
- also called minimal key
- Must be unique within its domain dom(Ai).
- Primary key is the term to denote a candidate
key that is chosen as the principal means of
identifying tuples within a relation.
ï 
 

- Entity Integrity Constraint. The primary key of a tuple
can never be null.
- Referential Integrity Constraint. A tuple that refers to
another tuple from another relation should refer to an
existing tuple.
I a given relation R1, a set of attributes FK is said to be a
foreign key of R1 referencing another relation R2, if the
following rules are met:
- The attribute in FK have the same domain as the
primary key of R2.
- For every tuple in R1, the attributes in its foreign key
FK either reference a tuple in R2 or is null.
Employee

! 
  
 ï  

Department

  
        

Foreign keys are diagrammatically depicted as arrows.


Note that foreign key can be from a relation to itself.
ï 
 

- Semantic Integrity Constraint. Constraints on the values
of attributes.
Example: DzThe salary of the employee cannot be more
than his/her supervisordz.
DzThe minimum age of an employee is 18 and
maximum is 65.dz
m
ï 
    


˜  ate ries f elatial el O eratis


1. etrievals ale stly y select ( ree letter si a
a rject (ete y ) eratis.
2. ates ca eit er e isert r e t le,
ati/ ificati f a existi t le r eleti a
existi t le.

    


 
 ï
- Selects tuples that satisfy a given predicate (appears as a
subscript to .The argument relation is in parentheses
after the .

Example:   !  

  

   !  

      !  


[ 
!!
 

- The SELECT operation is unary. It operates on only one
relation.
- Selection predicates are applied to each tuple
individually in the relation. Hence the predicate cannot
span in more than one tuple.
- The degree of the relation result is the same as that of the
original R.

- |  
 ïϐ |ï|
- The select operation is commutative:

 (
  (
ï  ï

[   

a1,ǥ,an(R)
A  
   
 is a unary operation
written as a1,ǥ,an(R) where 1,..., is a set of attribute
names.

Example: student_number, student_name(student)


    
2010-01 Angelo Macha

2010-02 Gringo Maquinay

2010-03 Willy Concha


[ 
[   

- The Project operation is unary. It operates on only one
relation.
- This operation removes duplicates in its results.
- The number of tuples returned by PR JECT is less than
or equal to number of tuples in the specified relation.
- When attribute list of PR JECT includes the superkey
then the number of tuples returned is equal to the
number of tuples in the specified relation R.
- The project operation is not commutative.
 

ï 
  

The fact that the result of a relational operation is itself a
relation.

ɕ student_number, student_name(ɗgrade > 85(student))


   


PassingStud  ɕ student_number, student_name( ɗ grade > 85(student))




 


´uery: to find the names of all bank customers who have


either an account or a loan or both.

customer_name(borrower) â customer_name(depositor)


 


Answer:
customer_name(borrower) â customer_name(depositor)

Requirements of union operation.


1. Relations must be compatible.
2. The relations must have the same
number of attributes.
3. The domains ( ) of the ith
attribute of relation r and ith attribute of
relation s must be the same, for all i.

 
    

The set-difference operation, denoted by -, allows us to find
tuples that are in one relation but not in another.
Example:
customer_name(depositor) - customer_name(borrower)

 
[  


- Denoted by a cross(x)
- This operation combine information from any two relations.
Ex.: Cartesian product of relations r1 and r2 is written as  .
Example:
borrower x loan
(borrower.customer.name, borrower.loan_number,
loan_number, loan.branch_name, loan.amount)
(customer.name, borrower.loan_number, loan_number,
branch_name, amount)
Sample ´uery: Find the name of all customers who have a loan
at the Perryridge branch.

    [  
   
ɗ borower.loan_number = loan.loan_number( ɗ branch_name = DzPerryridgedz(borrower x loan))

 ocustomer_name ɗ borower.loan_number = loan.loan_number(

ɗ branch_name = DzPerryridgedz(borrower x loan)))



ï   

- Denoted by the lowercase Greek letter rho (
- Syntax: (E)
-    (E)
- Ex.:

 ɗ account.balance = d.balance(account x (account))



 
 
r <- r Ȃ E
Where r is a relation and E is a relational-algebra expression.
Examples:
r 
 
r <- r U E
Where r is a relation and E is a relational-algebra expression.
Example:

 
r <- F1, F2,ǥ,Fn(r)
Where each Fi is either the ith attribute of r, if the ith attribute
is not updated, or, if the attribute is to be updated, Fi is an
expression, involving only constant and the attributes of r,
that gives the new value for the attribute.
Example:
Account <- account_number, branch_name, balance* 1.05(account)
Bibliographical Notes
E. F. Codd of the IBM San Jose Research Laboratory proposed
the relation model in the late 1960s (Codd[1970]). This
work led to the prestigious ACM Turing Awad to Codd in
1981
After Codd published his original paper, several research
projects were formed with the goal of construction practical
relational database systems including System R at the IBM
San Jose Research Laboratory, Ingres at the Univeristy of
California at Berkeley and ´uery-by-Example at the IBM
T.J. Watson Research Center.
 
- Based on the concept of mathematical relation
- Building blocks: a relation comprising of attributes
within domains
- Tuples + Schema = Relation
- Properties: rdering, Duplicates
- Constraints: Key Constraints, entity constraints,
referential integrity constraint
- Basic Retrieval operators: Select, Project
- Composability of relational operators and Cartesian join
Many relational database products are now commercially
available. These include IBMǯs DB2, racle, Sysbase,
Informix, and MS S´L Server. pen source relational
database systems include MyS´L and PostgreS´L.
Database products designed for personal use include
MS Access and Foxpro(?).
Advanced Database
Management System

angelo g. macha
grino maquinay

Thank you. l

References: Dr. S. Srinath, Indian Institute of Technology Madras


Database Concepts, 5th Ed. By Silberschatz, Korth and Sudarshan

Вам также может понравиться