THEORETICAL RELATIONAL LANGUAGES
Theoretical
relational languages to use with the
relational model.
1.Relational algebra
2.Relational calculus
RELATIONAL ALGEBRA
1. Union
2. Intersection
3. Difference
4. Projection
5. Selection
6. Product
7.Assignment
8. Join
9. Division
UNION
 The union of two tables results in
retrieval of
ALL rows that are in one or both
tables.
 there is a basic requirement to perform a
union operation on two tables.
 both tables must have the same degree.
 the domain of the corresponding
columns in two tables must be same.
Syntax:
TABLE_A=PROJ2002 U PROJ2003
INTERSECTION:
The intersection of two tables produces a
table with rows that are in both tables.
SINTAX:
TABLE_B=PROJ2002PROJ2003
DIFFERENCE
The difference of two tables
produces a tables with rows that are
present in the first table but not in the
second table.
SYNTAX:
TABLE_D=PROJ2003_PROJ2002
PROJECTION
The projection operation returns
the “vertical slices” of a table.
SYNTAX:
TABLE_E=PARTS( PartDes, cost)
SELECTION
The section operation selects rows from a table based
on a condition or conditions. The conditional
operators (=,<>,>,>=,<,<=)and the logical operators .
SYNTAX:
TABLE_F = sel (PARTS :cost >10.00)
PRODUCT
A product of two table is a combination
everything in both tables. It is also known as a cartesian
product.
SYNTAX
TABLE_G=EMPLOYEE.DEPARTMENT
ASSIGNMENT:
this operation creates a new table from existing
Tables .
ASSIGNMENT
This operation creates a new table new existing tables.
We have been doing it throughout all the other operations.
EXAMBLES
TABLE_A=PROJ2002 U PROJ2003
TABLE_C=PROJ2002 – PROJ2003
JOIN
the join is one of the most important operations because
of its ability to get related data from a number of tables.
EXAMBLES
TABLE_H=join(EMPLOYE ,DEPARTMENT :
DeptNo=Dept NO)
DIVISION
The division operation is the most
difficult operation to comprehend.
EXAMPLE:
TABLE_I=PRJPARTS/PROJ
RELATIONAL CALCULUS:
Relational calculus is a nonprocedural
language.
SYNTAX
Result=(column list):Expression
DATA MODELING AND
NORMALISATION
DATA MODELING
A model is a simplified version of real-
life,
Complex objects.
 An excellent communication tool
 A simple graphical representation of data
DEPENDENY
Every table in the database should have a primary
key which uniquely identifies an entity.
 Total or full dependency
 partial dependency
 Transitive dependency
DATABASE DESING
Relational database design involves an attempt to
synthesize the database structure to get the “first
draft”.
NORMAL FORMS
 anomalies
 first normal form
 second normal form
 third normal form
ANOMALIES
A Deletion anomaly results when the deletion of
information about one entity to the deletion of
information about another entity.
FIRST NORMAL FORM
The primary is defined. The includes a
composite key if a single column cannot be used
primary key.
SECOND NORMAL KEY
 All INF requirements are fulfilled
 There is no partial dependency.
THIRD NORMAL FILE
 All 2nf requirement are fulfilled
 There is no transitive dependency.
A table that has transitive dependency is not
in 3NF, but it need to be decomposed further
to achieve 3NF.
DEPENDENCY DIAGRAMS
The primary key components are
highlighted.
They are in bold letters and in boxes with a
darker border.
CONVERSION FROM 1NF TO 2NF
First write each primary key components on a
separate line because they will become
primary key in two new tables.
CONVESION FROM 2NF TO 3NF
 Move columns with the transitive
dependency to a new table.
 Keep the primary key of the new table as a
foreign key in the existing table.
DENORMALIZATION
The normalization process splits tables in to
smaller table. These tables are joined through
common columns to retrieve information
from different tables.
ANOTHER EXAMPLE OF
NORMALIZATION
1.Total dependency
2.Partial dependency
3.Transitive dependency
1. TOTAL DEPENDENY
Jery num, points score year ,games player,
team id, team name and team Loc columns are
dependent on primary key columns player id
and year.
2.PARTIAL DEPENDENCY
Player name and birth date columns are
dependent on primary key column player id
only.
3.TRANSITIYE DEPENDENCY
Team name and team loc columns are
dependent on non –key column team id.

OrACLE RELATIONAL

  • 1.
    THEORETICAL RELATIONAL LANGUAGES Theoretical relationallanguages to use with the relational model. 1.Relational algebra 2.Relational calculus
  • 2.
    RELATIONAL ALGEBRA 1. Union 2.Intersection 3. Difference 4. Projection 5. Selection 6. Product 7.Assignment 8. Join 9. Division
  • 3.
    UNION  The unionof two tables results in retrieval of ALL rows that are in one or both tables.  there is a basic requirement to perform a union operation on two tables.  both tables must have the same degree.  the domain of the corresponding columns in two tables must be same.
  • 4.
    Syntax: TABLE_A=PROJ2002 U PROJ2003 INTERSECTION: Theintersection of two tables produces a table with rows that are in both tables. SINTAX: TABLE_B=PROJ2002PROJ2003
  • 5.
    DIFFERENCE The difference oftwo tables produces a tables with rows that are present in the first table but not in the second table. SYNTAX: TABLE_D=PROJ2003_PROJ2002 PROJECTION The projection operation returns the “vertical slices” of a table. SYNTAX: TABLE_E=PARTS( PartDes, cost)
  • 6.
    SELECTION The section operationselects rows from a table based on a condition or conditions. The conditional operators (=,<>,>,>=,<,<=)and the logical operators . SYNTAX: TABLE_F = sel (PARTS :cost >10.00)
  • 7.
    PRODUCT A product oftwo table is a combination everything in both tables. It is also known as a cartesian product. SYNTAX TABLE_G=EMPLOYEE.DEPARTMENT ASSIGNMENT: this operation creates a new table from existing Tables .
  • 8.
    ASSIGNMENT This operation createsa new table new existing tables. We have been doing it throughout all the other operations. EXAMBLES TABLE_A=PROJ2002 U PROJ2003 TABLE_C=PROJ2002 – PROJ2003 JOIN the join is one of the most important operations because of its ability to get related data from a number of tables. EXAMBLES TABLE_H=join(EMPLOYE ,DEPARTMENT : DeptNo=Dept NO)
  • 9.
    DIVISION The division operationis the most difficult operation to comprehend. EXAMPLE: TABLE_I=PRJPARTS/PROJ RELATIONAL CALCULUS: Relational calculus is a nonprocedural language. SYNTAX Result=(column list):Expression
  • 10.
    DATA MODELING AND NORMALISATION DATAMODELING A model is a simplified version of real- life, Complex objects.  An excellent communication tool  A simple graphical representation of data
  • 11.
    DEPENDENY Every table inthe database should have a primary key which uniquely identifies an entity.  Total or full dependency  partial dependency  Transitive dependency
  • 12.
    DATABASE DESING Relational databasedesign involves an attempt to synthesize the database structure to get the “first draft”. NORMAL FORMS  anomalies  first normal form  second normal form  third normal form
  • 13.
    ANOMALIES A Deletion anomalyresults when the deletion of information about one entity to the deletion of information about another entity. FIRST NORMAL FORM The primary is defined. The includes a composite key if a single column cannot be used primary key. SECOND NORMAL KEY  All INF requirements are fulfilled  There is no partial dependency.
  • 14.
    THIRD NORMAL FILE All 2nf requirement are fulfilled  There is no transitive dependency. A table that has transitive dependency is not in 3NF, but it need to be decomposed further to achieve 3NF. DEPENDENCY DIAGRAMS The primary key components are highlighted. They are in bold letters and in boxes with a darker border.
  • 15.
    CONVERSION FROM 1NFTO 2NF First write each primary key components on a separate line because they will become primary key in two new tables. CONVESION FROM 2NF TO 3NF  Move columns with the transitive dependency to a new table.  Keep the primary key of the new table as a foreign key in the existing table.
  • 16.
    DENORMALIZATION The normalization processsplits tables in to smaller table. These tables are joined through common columns to retrieve information from different tables. ANOTHER EXAMPLE OF NORMALIZATION 1.Total dependency 2.Partial dependency 3.Transitive dependency
  • 17.
    1. TOTAL DEPENDENY Jerynum, points score year ,games player, team id, team name and team Loc columns are dependent on primary key columns player id and year. 2.PARTIAL DEPENDENCY Player name and birth date columns are dependent on primary key column player id only. 3.TRANSITIYE DEPENDENCY Team name and team loc columns are dependent on non –key column team id.