0% found this document useful (0 votes)
19 views35 pages

RDBMS11 12july

Uploaded by

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

RDBMS11 12july

Uploaded by

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

Properties of a relational model

(Codd’s 12 rules or equivalent)


Dr. Edgar F. Codd, the pioneer of relational databases, proposed a set of 12
rules to define what is required from a database management system (DBMS)
for it to be considered relational. These rules serve as a guideline to ensure
the database system fully exploits the relational model’s potential.
Rule 1. The Information Rule:
It states that all information in a relational database is represented
explicitly at the logical level and in exactly one way: as values in tables.
Rule 2. The Guaranteed Access Rule:
Each and every datum already in atomic values in a relation database
is guaranteed to be logically accessible by using a combination of table name,
primary key, column name.
Rule 3: Systematic Treatment of Null Values
Null values are not empty character string or a string of blank
characters. It is not zero or any other number. It is missing information
or inapplicable information and that should be treated in a systematic
way by the RDBMS.
Rule 4: Dynamic Online Catalog:
Database description (catalog) is represented at the logical level in
the same way as ordinary data. this allows authorized users to query the
catalog using the same relational language (eg. SQL) as they use to
query regular data.
Rule 5: The Comprehensive Data Sublanguage Rule:
A relational system may have several language and various mode of
terminal use. There should be at least one language that support all these.
1. Can be used both interactively and within application programs.
2. Support data definition operations (creation, modification, and
deletion of tables).
3. Support data manipulation operations (insertion, update, deletion,
and retrieval od data).
4. Support integrity constraints.
5. Support authorization.
6. Support transaction boundaries (begin, commit and rollback)

• Rule 6: The view updating rule:


All views that are theoretically updateable must be updateable by
the system.
• Rule 7: Possible for higher level Insert, Update, Delete
This means that insert, update and delete operation should be operable
on sets of rows.
• Rule 8: Physical Data Independence
Changes to the physical storage of data or to the access methods must
not require changes to the application programs.
• Rule 9: Logical Data Independence
Changes to the logical structure (tables, columns, etc.) must not
necessitate changes in the application programs, provided that the new
structure retains all information that was present in the old structure.
• Rule 10: Integrity Independence
Integrity constraints that are specific to a particular relational database
must be defined in the relational data sublanguage and not in the application
program also it should be stored in the catalog.
• Rule 11: Distribute Independence
Should have enough backup for the database at a distant place and
it should not be known to the end user.

• Rule 12: The Non-subversion Rule


If a relational system has a low level language (single-record-at-
a-time), then that low level language cannot be used to either subvert or
bypass the integrity rules and constraints express in the higher level
relational language (eg SQL).
Concepts of keys
• Key/superkey
• Candidate key
• Primary key
• Alternate key
• Foreign key
• Key/superkey
An attribute or a combination of attributes that can uniquely
identify each tuple in a relation is called a key.
Candidate key
The minimal superkey that uniquely identifies rows/tuples in a table.
There can be a number of candidate key in a relation.
Primary key
A Candidate key that is used to uniquely identified rows in the
relation.
Alternate key or secondary key
All the remaining candidate keys other than the primary key are
called the alternate keys.
• Foreign Key
Foreign key is an attribute or a set of attribute that is used to link
to another relation or table.
Relational Algebra
• A data model must include a set of operations to manipulate the
database, in addition to the data model’s concepts for defining
database structure and constraints.
• The basic set of operations for the relational model is the relational
algebra. These operation enables a user to specify basic retrieval
requests.
• It is one of the two formal languages for the relational model. The
other is relational calculus.
Importance of relational algebra
• First, the provides a formal foundation for relational model
operations.
• Second is very important, it is used as a basis for implementing and
optimizing queries in relational database management system
(RDBMS).
• Third, some of the concepts are incorporated into the SQL standard
query language for RDBMS.
Relational Algebra operations:

Fundamental operations: Additional operations:


1. Select 1. Set intersection
2. Assignment operation
2. Project
3. Natural join
3. Union 4. Division operation
4. Set difference 5. Outer join:
5. Cartesian product Left outer join
6. Rename Right outer join
Full outer join
h
Unary Relational Operations (SELECTION, PROJECTION, RENAME)

Relational Algebra operations - Set theory


1. Union
2. Set intersection
3. Set difference
4. Cartesian product

Binary Relation Operations

Join (Theta join, EquiJoin, Natural Join), outer join, Division operation
SELECT operation
• The SELECT operation is used to select a subset of the tuples from a
relation that satisfy a selection condition.
• The select operation is denoted by

For eg. DNO=4(EMPLOYEE)

SALARY>30000(EMPLOYEE)
Ex: select the EMPLOYEE tuples whose department no. is 2.

EMPLOYEE Fname LName DNo

Tom Ford 3

Rani Devi 2

Anny Chanu 2

DNo=2(EMPLOYEE)
Result:
Fname Lname DNo

Rani Devi 2

Anny Chanu 2
The PROJECT operation
• The project operation is used to select certain columns from the table
and discards other columns.
• The general form of the project operation is as follows

Eg.,Lname, Fname, salary
sex,salary(EMPLOYEE)
EMPLOYEE Fname LName DNo

Tom Ford 3

Rani Devi 2

Anny Chanu 2

Fname, DNo(EMPLOYEE)
Result:
Fname DNo

Rani 2

Anny 2
Rename operation
• It is used to rename relation name or column name
•  (rho) symbol is used to represent rename operation
• Eg  (EMPLOYEE)
Ex:

EMPLOYEE Fname LName DNo

Tom Ford 3

Rani Devi 2

Anny Chanu 2

S firstname lastname DNo

Tom Ford 3

Rani Devi 2

Anny Chanu 2
SET OPERATION
Relational Algebra operations - Set theory
1. Union
2. Set intersection
3. Set difference
4. Cartesian product
Important points
• The set operations are binary operations that is, each is applied to two sets
of tuples.
• When these three operations are adapted to relational databases, the two
relations on which any of these three operations are applied must have the
same type of tuples; this condition has been called union compatibility.
• Two relations R(A1,A2,A3, …, An) and S(B1,B2, B3, …, Bn) are said to be
union compatible if they have the same degree n and dom(Ai)= dom(Bi) for
i<=n.
• This means that the two relations have the same number of attributes, and
each corresponding pair of attributes has the same domain.
• Union: The result of this operation, denoted by RUS, is a relation that
includes all tuples that are either in R or in S or in both R and S.
Duplicate tuples are eliminated.
• Intersection: The result of the intersection operation, denoted by RS,
is a relation that includes all tuples that are in both R and S.
• SET DIFFERENCE (MINUS): The result of this operation, denoted by R-S,
is a relation that includes all tuples that are in R but not in S.
R Fname LName S Fname Lname

Tom Ford Rani Devi


Rani Devi
Anny Chanu
Anny Chanu
Silvia Devi

RUS Fname Lname

Tom Ford

Rani Devi

Anny Chanu

Silvia Devi
R Fname LName S Fname Lname

Tom Ford Rani Devi


Rani Devi
Anny Chanu
Anny Chanu
Silvia Devi

RS Fname Lname

Rani Devi

Anny Chanu
R Fname LName S Fname Lname

Tom Ford Rani Devi


Rani Devi
Anny Chanu
John Smith
Silvia Devi
Anny Chanu

R-S Fname Lname

Tom Ford

John Smith
Cartesian product (or Cross product)
operation
• This operation is denoted by .
• This is a binary set operation, but the relations on which it is applied
do not have to be union compatible.
• This operations is used to combine tuples from two relations in a
combinatorial fashion.
• The result of R(A1,A2, …, An)  S(B1,B2, …, Bn) is a relation Q with
degree n+m attributes Q (A1,A2, …, An,B1,B2, …, Bn).
• The resulting relation Q has one tuple for each combination of tuples-
one from R and one from S.
• If R has nR tuples and S has nS tuples then R  S has nR * nS tuples.
R A B S C D E

101 104
P O X
102 105

103 106 Q B Y

C (RxS) A B C D E

101 104 P O X

101 104 Q B Y

102 105 P O X

102 105 Q B Y
JOIN operation
The join operation is a binary relational operation, denoted by , is
used to combine related tuples from two relations into a single tuples.
Syntax: R S
Example:
Dept_Mgr  DEPARTMENT EMPLOYEE
Or
Temp DEPARTMENT EMPLOYEE
Dept_Mgr   Temp
DEPARTMENT DName DNo Mgr_SSN

Research 2 553621425

Finance 3 996856974

EMPLOYEE SSN Fname Lname DNo

123658974 Alex Singh 2

553621425 Alfred Smith 5

996856974 Elvis Scott 5

859689742 Peter Williams 2


Dept_Mgr DName DNo Mgr_SSN SSN Fname Lname DNo

Research 2 553621425 553621425 Alfred Smith 5

Finance 3 996856974 996856974 Elvis Scott 5


Different types of joins--Theta join, Equi join,
Natural join
R A1 A2
Theta join (): 20 25
<join condition>:  80 40
is the attributes of R
S B1
is the attributes of S
 {=, <,<=,>,>=,} 50

35
S
R A1 A2 S B1

20 25 50

80 40 35

1. R S
2. R S
3. R S
4. R S
5. R S
Equijoin operation
In Equijoin the comparison operator  is only “=“.
Natural join
• In equi join a pair of attributes having identical values is present.
• Natural join operation denoted by
* was introduced to get rid of the second(superfluous) operation in
an equijoin operation.
• The standard definition of Natural Join requires that the two join
attributes have the same name in both relations. If this is not the
case, a renaming operation is applied first.
PROJECT PID PName DNum DEPARTMENT DNo Mgr_SSN

101 ProjextX 1 1 553621425

102 ProjectY 2 2 996856974

103 ProjectZ 2

Proj_Dept  PROJECT 

OR

Dept 
Proj_Dept  PROJECT *
Result:-

Proj_Dept PID PName DNum Mgr_SSN

101 ProjextX 1 553621425

102 ProjectY 2 996856974

103 ProjectZ 2 996856974

You might also like