Professional Documents
Culture Documents
Relational databases are the most widely used databases in commercial applications like as
banking system, railway-reservation system, etc.
A relational data model was first introduced by Dr. Edgar F. Codd of IBM Research in 1970.
He represented the overview of the relational model in his paper entitled "A Relational Model
of Data for Large Shared Data Banks"
Popular commercial RDBMS for large databases include Oracle, Microsoft SQL Server, Sybase
SQL Server, and IBM's DB2.
Domain :
A domain of an attribute is a set of permitted values for that attribute
For example, if the bank is organized in three branches, named 'vvn', 'ksad' and
'anand', then, the domain of attribute bname is {'vvn', 'ksad', 'anand'}.
A value for a branch name must be one of these three values in any relation.
Similarly, a domain for column ano in Account table is a set of strings starting from
'A followed by unique numerical value, such as {A01, A02, A03, A04, A05}.
A domain is atomic if elements of domain are considered to be indivisible units.
For example, a domain for bname is an atomic domain.
A domain for some attribute, say address may not be atomic, as address can be divided into
sub-parts such as society, city, and pincode.
A domain of an attribute should be atomic
An atomic domain is preferable rather than a non-atomic domain.
http://gtustudymaterial.blogspot.in/
1
The Relation Algebra and calculus
Keys of Relations
Super Key
"A super key is a set of one or more attributes that allows to identify each tuple
uniquely in a relation."
For example, consider a relation Customer with attributes cid, cname, address,
and contact_no.
In this relation, each tuple represents an individual customer.
Here, the cid attribute can distinguish each tuple from another.
So, cid is a super key for Customer relation.
Relation Key
"A super key for which no subset is a super key is called a relation key."
In other words, relation key is a minimal super key.
A relation key is also referred as 'key' only.
A relation key is sufficient to identify each and every tuple uniquely within a
relation.
A relation key cannot have null or duplicate values, as well as it does not contain any
redundant attribute.
There can be more than one relation keys for the same relation. For example, for
Customer relation, {cid} as well as {cname, address} are relation keys.
Candidate Key
"If a relation contains more than one relation keys, then, they each are called
candidate key."
For example, for Customer relation, {cid} as well as {cname, address} are relation
http://gtustudymaterial.blogspot.in/
2
The Relation Algebra and calculus
Alternate Key
"An alternate key is a candidate key that is not chosen by the database designer
to identify tuples uniquely in a relation."
For example, if database designers choose candidate key cid to identify all customers
uniquely, then, another candidate key {cname, address} is an alternate key.
Foreign Key
"A foreign key is a set of one or more attributes whose values are derived from
the key attribute of another relation."
“Explain to the ch-5”
RELATIONAL ALGEBRA
Relational algebra is a collection of formal operations acting on relations and producing relations
as results.
Six basic operators
select:
project:
union:
set difference: –
Cartesian product: x
Rename:
The operators take one or two relations as inputs and produce a new relation as a result.
Relational algebra is a Procedural language.
http://gtustudymaterial.blogspot.in/
3
The Relation Algebra and calculus
http://gtustudymaterial.blogspot.in/
4
The Relation Algebra and calculus
Example : Combine only consistent information from Account and Branch relation.
As shown in figure 3.11, natural join operation yield only consistent and useful information. It
removes unnecessary tuples as well as duplicate attributes. This makes the retrieval of information
from multiple relations very easy and convenient.
http://gtustudymaterial.blogspot.in/
5
The Relation Algebra and calculus
NAME ID
Rahul 10
Vishal 20
ID CITY
30 Bombay
20 Madras
40 Bombay
NAME ID CITY
Vishal 20 madras
The outer join operation can be divided into three different forms :
Left outer join ( )
Right outer join ( )
Full outer join ( )
http://gtustudymaterial.blogspot.in/
6
The Relation Algebra and calculus
NAME ID CITY
Rahul 10 Null
Vishal 20 madras
NAME ID CITY
Null 30 Bombay
Vishal 20 madras
Null 40 Bombay
http://gtustudymaterial.blogspot.in/
7
The Relation Algebra and calculus
Example: List out all persons who are customers but not employees.
Figure 3.8: Name of persons who are customers but not employees
http://gtustudymaterial.blogspot.in/
8
The Relation Algebra and calculus
http://gtustudymaterial.blogspot.in/
9
The Relation Algebra and calculus
Example-8: Combine only consistent information from Account and Branch relation.
Query : (Account X Branch)
Account.bname = Branch.bname '
Observe that for all tuples of S, all possible pairs - (al, b1) and (al, b2) - are present in R for
value al of attribute A. So, al is included in resultant relation T.
Similarly, for all tuples of S, all possible pairs - (a3, b1) and (a3, b2) - are present in R for
value a3 of attribute A. So, a3 is also included in T.
But, for a2, the combination (a2, b1) is present in R, but, (a2, b2) is not present. So, a2 is
not included in T.
http://gtustudymaterial.blogspot.in/
10
The Relation Algebra and calculus
Similarly, for a4, the combination (a4, b2) is present in R, but, (a4, b1) is not present. So, a4 is
not included in T.
Example: Find out id numbers of employees who work on all the projects that 'Asmita' works.
Step-1 - Retrieve the list of projects on which 'Asmita' works.
http://gtustudymaterial.blogspot.in/
11
The Relation Algebra and calculus
Fig 1.0
STUDENT-1
STUDEN STUDENT- COURS
T# NAME E
A101 Astor APPCO
M
B334 Bernstein INFTE
C
J326 Jones APPCO
M
STUDENT-2
STUDEN STUDENT- COURS
T# NAME E
J326 Jones APPCO
M
A423 Astor APPCO
M
MODULE
MODUL MODULE-
E# NAME
CS301 IS
CS302 DBS
ASSESSMENTS
STUDE MODU EX
NT # LE # A
M
A101 CS301 60
A101 CS302 50
J326 CS302 70
http://gtustudymaterial.blogspot.in/
12
The Relation Algebra and calculus
http://gtustudymaterial.blogspot.in/
13