You are on page 1of 14

Relational Database

Group 2
A Relational Database is a type of database that stores and provides access
to data points that are related to one another. The columns of the table hold
Relational Database
attributes of the data, and each record usually has a value for each attribute,
making it easy to establish the relationships among data points

The “bi” in a binary relation R refers to the fact that R has two columns when
we write R as a table. It is often useful to allow a table to have an arbitrary
number of columns. If a table has n columns, the corresponding relation is
called an n-ary relation.
Table 2.6.1 represents a 4-ary relation. This table expresses the relationship
among identification numbers, names, positions, and ages.
Example
We can also express an n-ary relation as a collection of n-tuples.

TABLE 2.6.1 PLAYER

ID Number Name Position Age

22012 Johnsonbaugh C 22
93831 Glover Of 24
58199 Battey P 18
84341 Cage C 30
01180 Homer Lb 37
26710 Score P 22
61049 Johnsonbaugh Of 30
39826 Singleton 2b 31
Database A Database is a collection of records that are manipulated by a computer.
For example, an airline database might contain records of passenger’s
reservations, flight schedules, equipment and so on. Computer system are
capable of storing large amounts of information in databases. The data are
available to various applications.

Database Management
System Database Management System (DBMS) are programs that help users
access the information in databases.
The relational model (RM) was designed to solve the problem of multiple
Relational Model
arbitrary data structures and was invented by Edgar F. Codd in 1970, is based
on the concept of an n-ary relation. We will briefly introduce some of the
fundamental ideas in the theory of relation databases.

Attributes The columns of an n-ary relation are called attributes.


Key
A single attribute or a combination of attributes for a relation is a Key if the
values of the attributes uniquely define an n-tuple

Query A database management system responds to queries. A query is a request for


information from the database.
The selection operator chooses certain n-tuples from a relation. For example,
for the relation PLAYER given in table 2.6.1,

Select PLAYER [Position = c]

ID Number Name Position Age


22012 Johnsonbaugh C 22

93831 Glover Of 24
58199 Battey P 18
84341 Cage C 30
01180 Homer 1b 37
26710 Score P 22
61049 Johnsonbaugh Of 30

39826 Singleton 2b 31

Will select the tuples


(22012, Johnsonbaugh, c, 22), ( 84341, Cage, c, 30).
Whereas the selection operator chooses rows of relation, the projection
chooses columns, In addition, duplicates are eliminated, For example, for the
relation PLAYER given by Table 2.6.1
Project PLAYER[Name, Position]

ID Number Name Position Age


22012 Johnsonbaugh C 22

93831 Glover Of 24
58199 Battey P 18
84341 Cage C 30
01180 Homer 1b 37
26710 Score P 22
61049 Johnsonbaugh Of 30

39826 Singleton 2b 31

Will select the tuples


(Johnsonbaugh, c), (Glover, of), Battey, p), (Cage, c), (Homer, lb),
(Score, p), (Johnsonbaugh, of), (Singleton, 2b).
The selection and projection operators manipulate a single relation. Join
manipulates two relations. The join operation on relation R1 and R2 begins by
examining all pairs of tuples, one from R1 and one from R2. If the join
condition is satisfied, the tuples are combined to form a new tuple. The join
Join condition specifies a relationship between an attribute in R1 and an attribute in
R2. For example, let us perform a join operation on Tables 2.6.1 and 2.6.2. As
the condition we take.

ID Number = PID
We take a row from Table 2.6.1 and row from Table 2.6.2 and if ID Number = PID, we combine the rows. For example, the
ID Number 01180 in the fifth row (01180, Homer, lb, 37) of Table 2.6.1 matches the PID in the fourth row (01180, Mutts) of
Table 2.6.2. These tuples are combined by the first writing the tuple from Table 2.6.1, following it by the tuple from the Table
2.6.2 and eliminating the equal entries in the specified attributes to give
(01180, Homer, lb, 37, Mutts),

TABLE 2.6.1 PLAYER TABLE 2.6.2 ASSIGNMENT

ID Number Name Position Age


22012 Johnsonbaugh C 22
93831 Glover Of 24 PID Team
58199 Battey P 18 39826 Blue Sox
84341 Cage C 30
01180 Homer 1b 37 26710 Mutts
26710 Score P 22
58199 Jackalopes
61049 Johnsonbaugh Of 30
39826 Singleton 2b 31 01180 Mutts
TABLE 2.6.3 PLAYER [ID Number = PID] ASSIGNMENT

ID Number Name Position Age Team

58199 Battey P 18 Jackalopes

01180 Homer 1b 37 Mutts

26740 Score P 22 Mutts

39826 Singleton 2b 34 Blue sox


Most queries to a relational database require several operations to
provide the answer

Describe operations that provide the answer to the query “Find the names of
all persons who play for some team”.
If we first join the relations given by Tables 2.6.1 and 2.6.2 subject to the
condition ID Number = PID, we will obtain Table 2.6.3, which lists all
persons who play for some team as well as other information. To obtain the Name
names, we need only project on the attribute Name. We obtain the relation.
Battey

Homer

Score

Singleton

Formally, the operations would be specified as

TEMP : = PLAYER [ID Number = PID] ASSIGNMENT


TEMP [Name]
Temp1

Describe operations that provide the answer to the query “Find the names of all
persons who play for the Mutts”. PID Team
If we first use the selection operator to pick the rows of Table 2.6.2 that 26740 Mutts
reference Mutts’ players, we obtain the relation.
01180 Mutts

If we now join Table 2.6.1 and the relation TEMP1 subject to ID Number
Temp2 = PID, we obtain the relation

ID Number Name Position Age Team

26740 Homer 1b 37 Mutts

01180 Score P 22 Mutts

Name
Homer If we project the relation TEMP2 on the attribute Name, we obtain the
relation
Score
Thank You

You might also like