0% found this document useful (0 votes)
13 views80 pages

Understanding the Relational Model in DBMS

The document provides an overview of the relational model in database management systems, explaining concepts such as relations, tuples, attributes, and domains. It details the structure of relation schemas, the operations of relational algebra including select, project, union, and set difference, and the constraints that can be applied to relations. Additionally, it discusses the importance of relational algebra as a query language for accessing and manipulating data within relational databases.

Uploaded by

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

Understanding the Relational Model in DBMS

The document provides an overview of the relational model in database management systems, explaining concepts such as relations, tuples, attributes, and domains. It details the structure of relation schemas, the operations of relational algebra including select, project, union, and set difference, and the constraints that can be applied to relations. Additionally, it discusses the importance of relational algebra as a query language for accessing and manipulating data within relational databases.

Uploaded by

owaishkhan898
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Data Base Management

System
Course Code: CSE201
Module II
Relational Model
Ms. Garima Srivastava
Asstt. Professor
Dept Of CSE/IT ASET
AUUP Lucknow
Relational Model
• The relational model represents the database as a
collection of relations.
• Informally, each relation resembles a table of values or, to
some extent, a flat file of records.
• It is called a flat file because each record has a simple
linear or flat structure.
• When a relation is thought of as a table of values, each
row in the table represents a collection of related data
values.
• A row represents a fact that typically corresponds
• to a real-world entity or relationship. 2
• The table name and column names are used to help to
interpret the meaning of the values in each row.
• In the formal relational model terminology,
– a row is called a tuple,
– a column header is called an attribute,
– and the table is called a relation.
• The data type describing the types of values that can
appear in each column is represented by a domain of
possible values.
3
Domains, Attributes, Tuples, and
Relations
• A domain D is a set of atomic values.
• By atomic we mean that each value in the domain is
indivisible as far as the formal relational model is
concerned.
• A common method of specifying a domain is to specify a
data type from which the data values forming the domain
are drawn.
• It is also useful to specify a name for the domain.
• The next slide shows the example if few of the domains
4
• Usa_phone_numbers. The set of ten-digit phone numbers valid in
the United States.
• Local_phone_numbers. The set of seven-digit phone numbers
valid within a particular area code in the United States. The use of
local phone numbers is quickly becoming obsolete, being
replaced by standard ten-digit numbers.
• Social_security_numbers. The set of valid nine-digit Social
Security numbers.
• Names: The set of character strings that represent names of
persons.
• Grade_point_averages. Possible values of computed grade point
averages; 5
• Employee_ages. Possible ages of employees in a
company; each must be an integer value between 15 and
80.
• Academic_department_names. The set of academic
department names in a university, such as Computer
Science, Economics, and Physics.
• Academic_department_codes. The set of academic
department codes, such as ‘CS’, ‘ECON’, and ‘PHYS’.
• The preceding are called logical definitions of domains. A
data type or format is also specified for each domain.
6
• For example, the data type for the domain Usa_phone_numbers
can be declared as a character string of the form (ddd)ddddddd,
where each d is a numeric (decimal) digit and the first three digits
form a valid telephone.
• The data type for Employee_ages is an integer number
between 15 and 80.
• For Academic_department_names, the data type is the set of all
character strings that represent valid department names.
A domain is thus given a name, data type, and format.

7
Relation Schema
• A relation schema R, denoted by R(A1, A2, ...,An), is
made up of
– a relation name R
– and a list of attributes, A1, A2, ..., An.
• Each attribute Ai is the name of a role played by some
domain D in the relation schema R.
• D is called the domain of Ai and is denoted by dom(Ai).
• A relation schema is used to describe a relation; R is
called the name of this relation.
8
• The degree (or arity) of a relation is the number of attributes n of
its relation schema.
• A relation of degree seven, which stores information about
university students, would contain seven attributes describing
each student as follows:
• STUDENT(Name, Ssn, Home_phone, Address, Office_phone,
Age, Gpa)
• Using the data type of each attribute, the definition is sometimes
written as:
• STUDENT(Name: string, Ssn: string, Home_phone: string,
Address: string, Office_phone: string, Age: integer, Gpa: real)
9
• A relation (or relation state) r of the relation schema R(A1,
A2, ..., An),
• Also denoted by r(R), is a set of n-tuples r = {t1, t2,..., tm}.
• Each n-tuple t is an ordered list of n values t =<v1, v2, ...,
vn>, where each value vi, 1 ≤ i ≤ n, is an element of
dom(Ai) or is a special NULL value.
• The ith value in tuple t, which corresponds to the attribute
Ai, is referred to as t[Ai] or [Link] (or t[i] if we use the
positional notation).
10
Relational Model Notation
• A relation schema R of degree n is denoted by R(A1,
A2, ..., An).
• The uppercase letters Q, R, S denote relation names.
• The lowercase letters q, r, s denote relation states.
• The letters t, u, v denote tuples.
• An attribute A can be qualified with the relation name R to
which it belongs by using the dot notation R.A—for
example, [Link] or [Link].
• An n-tuple t in a relation r(R) is denoted by t = <v1, v2, ...,
vn>, where vi is the value corresponding to attribute Ai.
11
Relational Model Constraints
• In a relational database, there will typically be many
relations, and the tuples in those relations are usually
• related in various ways.
• The state of the whole database will correspond to the
• states of all its relations at a particular point in time.
• There are generally many restrictions or constraints on
the actual values in a database state

12
• Constraints on databases can generally be divided into three main
categories:
• Constraints that are inherent in the data model. We call these
inherent model-based constraints or implicit constraints.
• Constraints that can be directly expressed in schemas of the data
model, typically by specifying them in the DDL We call these
schem
• Constraints that cannot be directly expressed in the schemas of
the data model, and hence must be expressed and enforced by
the application programs.
• We call these application-based or semantic constraints or
business rules or explicit constraints.
13
Relational Algebra
• Every database management system must define a query
language to allow users to access the data stored in the
database.
• Relational Algebra is a procedural query language used to
query the database tables to access data in different
ways.
• In relational algebra, input is a relation(table from which
data has to be accessed) and output is also a relation(a
temporary table holding the data asked for by the user).

14
15
• Relational Algebra works on the whole table at once,
• so we do not have to use loops etc to iterate over all the
rows(tuples) of data one by one.
• All we have to do is specify the table name from which we
need the data,
• and in a single line of command, relational algebra will
traverse the entire given table to fetch data for you.

16
• The primary operations that we can perform using RA are:
• Select
• Project
• Rename
• Set Difference
• Cartesian product
• Natural Join
• Set Intersection
• Division
• Assignment
• Union 17
Select Operation (σ)
• This is used to fetch rows(tuples) from table(relation) which
satisfies a given condition.
• Syntax: σp(r)
• Where, σ represents the Select Predicate,
• r is the name of relation(table name in which you want to look for
data),
• and p is the prepositional logic, where we specify the conditions
that must be satisfied by the data
• In prepositional logic, one can use unary and binary operators like
=, <, > etc, to specify the conditions.

18
• Let's take an example of the Student table we specified
above in the Introduction of relational algebra, and fetch
data for students with age more than 17.
• σage > 17 (Student)
• You can also use, and, or etc operators, to specify two
conditions, for example,
• σage > 17 and gender = 'Male' (Student)
• This will return tuples(rows) from table Student with
information of male students, of age more than 17.
19
• Let's take an example of the Relation Loan.
• Loan(branch_name,loan_no,amt)
• Borrower(cust_name,loan_no)
• Depositor(cust_name,acc_no)
• Customer(cust_name,cust_street,cust_city)
• Branch(branch_name,branch_city,asset)
• Account(branch_name,acc_no,bal)
• Loan_officer(cust_name,banker_name,loan_no)

20
• Select all tuples of the ‘loan relation where the branch is
‘lucknow’
• Find all tuples in which amount lent is more than 1200
• Select all tuples where branch is lucknow and amount is
1200
• Find all customers who have same name as the name of
the loan officer.

21
• σ branch_name=“lko” (Loan)
• Select * from loan where Branch_name=“lko”;
• σ amt>1200 (Loan)
• Select * from loan where amt>1200
• σ branch_name=“Lko” ^ amt=1200 (Loan)
• Select * from loan where branch_name=“lko” AND
amt=1200;
• σ cust_name=banker_name (Loan_officer)
• Select*from Loan_officer where cust_name=banker_name;
22
Project Operation (∏)
• Project operation is used to project only a certain set of
attributes of a relation.
• In simple words, If you want to see only the names all of
the students in the Student table, then you can use
Project Operation.
• It will only project or show the columns or attributes asked
for, and will also remove duplicate data from the columns.
• Syntax: ∏A1, A2...(r)
• where A1, A2 etc are attribute names(column names).

23
• For example,∏Name, Age(Student)
• Above statement will show us only the Name and Age
columns for all the rows of data in Student table.
• Question:
• List all loan numbers and amount of the loan.
• Find the names of all customer with a loan in the bank
• Find the name of all customers with an account in the
bank
• Find those customer who live in lucknow.
24
• ∏loan_no,amt (Loan)
Select loan_no ,amt from loan;
• ∏cust_name(Borrower)
Select cust_name from Borrower;
• ∏cust_name(Depositor)
Select cust_name from Depositor;
• ∏cust_name(σ cust_city=“lko”(customer))
Select cust_name from customer where cust_city=“lko”;

25
Union Operation (∪)
• This operation is used to fetch data from two
relations(tables) or temporary relation(result of another
operation).
• For this operation to work the following criteria must be met:
1. The relations(tables) specified should have same number of
attributes(columns) and
2. The domain of ith attribute of both relation must be same for all ‘i’.
• The duplicate tuples are automatically eliminated from the
result.
• Syntax: A ∪ B (where A and B are relations.)
26
• Find the name of all branch customers who have either
an account , a loan or both.
• Retrieve the names of all the clients and salesman in the
city of Mumbai from the tables Client_master and
Salesman_Master.

27
• Question:
• Find the name of all branch customers who have either an
account , a loan or both.
• ∏cust_name(Borrower)U ∏cust_name(Depositor)
• Select cust_name from Borrower UNION cust_name from
Depositor;
• Retrieve the names of all the clients and salesman in the city of
Mumbai from the tables Client_master and Salesman_Master .
• ∏Name(σ city=“Mumbai”(client_Master))U
∏salesman_name(σcity=“Mumbai”(Sales_Master))
28
Set Difference (-)
• This operation is used to find data present in one relation
and not present in the second relation.
• This operation is also applicable on two relations, just like
Union operation.
• Syntax: A - B
• where A and B are relations.
• For example, if we want to find name of students who
attend the regular class but not the extra class, then, we
can use the below operation:
• ∏Student(RegularClass) - ∏Student(ExtraClass)
29
• Find all those customer of the bank who have an account
but not taken a loan.
• ∏cust_name(Depositor) - ∏cust_name(Borrower)

30
Set Intersection (∩)
• Set intersection operation can be denoted by ‘∩’.
• R∩S returns a relation instance containing all tuples that
occur in both R and S.
• The relations R and S
– must be union-compatible,
– and the schema of the result is defined to be identical to the
schema of R. r-s
• (r ∩s)=r-(r-s)
• (s ∩r)=s-(s-r)
r s 31
• We can rewrite any RA using set intersection by replacing
the intersection operation with a pair of set-difference
operation .
• Find all customers who have both a loan and an account.
• ∏cust_name(Depositor) ∩∏ cust_name(Borrower)

32
Rename Operation (ρ)
• It is used for storing the result of an expression in the form of a
table by some new name.
• Unlike relations in the database , the results of the relational
algebra expression do not have a name that can be used to refer
to them .
• Rename operation gives name to the output relation for any query
operation which returns result like Select, Project etc. Or to simply
rename a relation(table).
• ρRelationNew( RelationOld)

33
• Renaming can be used by three methods, which are as follows −
• Changing name of the relation.
• Changing name of the attribute.
• Changing both.
• The student table is renamed with new_student
–ρ (student)
new_student

• The name, branch column of student table are renamed


and newbranch respectively
ρ newname,newbranch(∏name,branch( student))
•ρ σx= amt>1200 (loan)
34
Cartesian Product BXL
• This is used to combine data from two different relations(tables)
into one and fetch data from the combined relation.
• Syntax: A X B
• For example, if we want to find the information for Regular Class
and Extra Class which are conducted during morning, then, we
can use the following operation:
•σ time = 'morning' (RegularClass X ExtraClass)
• For the above query to work, both RegularClass and ExtraClass
should have the attribute time.

35
Cust_name Loan_no
Ram L-11 B_name Loan_no Amt
Shyam L-21 [Link] L-11 200000
John L-11 G.N L-21 400000
Borrower Loan
N1=no. of rows in B N2=no. of rows in L Total No. of rows =N1XN2 =3X2=6

Cust_name B_name B.Loan_no L.Loan_no Amt


BxL Ram H.G L-11 L-11 200000 Total No. of cols =B+L
Ram G.N L-11 L-21 400000
Shyam H.G L-21 L-11 200000
Shyam G.N L-21 L-21 400000
John H.G L-11 L-11 200000
John G.N L-21 L-21 400000
36
• In this table entire data is not correct.
• Cartesian product denoted by a cross allows us to
combine information from any two relations.
• We write the cartesian product of any two relations (r1
and r2) as (r1Xr2)
• Where r1(a,b) and r2(c,a)
• R(r1.a,b,c,r2.a)
Attributes of the
Cratesian Product
37
• Find the name of all customers who have a loan at the
Gomti Nagar branch.
• ∏cust_name(σ b_name=“G.N”(σB.Loan_no=L.Loan_no(BXL))
• Also,
• ∏cust_name(σ b_name=“G.N”^B.Loan_no=L.Loan_no(BXL))
• Constraint is important while using BXL since many tuples
are wrong in it.

38
Natural Joins(B L)
• The JOIN operation, denoted by , is used to combine related
tuples from two relations into single “longer” tuples.
• This operation is very important for any relational database with
more than a single relation because it allows us to process
relationships among relations.
• The JOIN operation can be specified as a CARTESIAN
PRODUCT operation followed by a SELECT operation.
• However, JOIN is very important because it is used very
frequently when specifying database queries.

39
• The natural Join operation forms a Cartesian Product of two
arguments to perform a selection forcing equality on those
attributes that appear in both relation schemas and finally
removes duplicate attributes.
• Natural Join is associative.
• Find the names of all customers who have loan in the bank and
find the amount of loan.
• ∏cust_name,loan_no,amt (B L)
• Or
• ∏cust_name,loan_no,amt (σ B.loan_no=L.loan_no(BXL))

40
Emp_name Street City Emp_name B_name Sal
C T Lko C M 100000
R T Knp R M 200000
S X Del G N 300000
W Y Mub W N 400000

E1 E2

Emp_name Street City B_name Sal


E1 E2 C T Lko M 100000
R T Knp M 200000
Loss of data W Y Mub N 400000

41
• The most common use of JOIN involves join conditions
with equality comparisons only.
• Such a JOIN, where the only comparison operator used
is =, is called an EQUIJOIN.
• Previous examples were EQUIJOINs.
• Notice that in the result of an EQUIJOIN we always have
one or more pairs of attributes that have identical values
in every tuple.
• Like in the case of the loan no. both the Bank and the
loan will have same loan no for each tuple.
42
Outer Join
• The outer-join operation is an extension of the join operation to
deal with missing information.
• There are three kinds:
• Left Outer Join : takes all the tuples in the left relation that did
not match with any tuple in the right relation.
• Adds the tuple with the Null value for all the other attribute from
the right relation.
• Right Outer Join : takes all the tuples in the right relation that
did not match with any tuple in the left relation.
• Adds the tuple with the Null value for all the other attribute from
the left relation.
43
• Full outer Join : Is the combination of left and right.
• All the rows of the column (common to both the relation)
will be considered.
• Suppose that we have the relations with the following
schemas, which contain data on full-time employees:
• employee (employee-name, street, city)
• ft-works (employee-name, branch-name, salary)

44
45
• Suppose that we want to generate a single relation with
all the information (street, city, branch name, and
• salary) about full-time employees.
• A possible approach would be to use the natural join
operation as follows:

46
• Notice that we have lost the street and city information
about Smith, since the tuple describing Smith is absent
from the ft-works relation;
• Similarly, we have lost the branch name and salary
information about Gates, since the tuple describing Gates
is absent from the employee relation.
• We can use the outer-join operation to avoid this loss of
information.

47
48
49
Assignment
• It is convenient at times to write a relational-algebra
expression by assigning parts of it to temporary relation
variables.
• The assignment operation, denoted by ←, works like
assignment in a programming language.
• temp1 ← ΠR−S (r)
• temp2 ← ΠR−S ((temp1 × s) − ΠR−S,S(r))
• result = temp1 − temp2

50
• The evaluation of an assignment does not result in any
relation being displayed to the user.
• Rather, the result of the expression to the right of the ← is
assigned to the relation variable on the left of the←.
• This relation variable may be used in subsequent
expressions.
• For relational-algebra queries, assignment must always
be made to a temporary relation variable.
• Assignments to permanent relations constitute a
database modification.
51
The Tuple Relational Calculus
• When we write a relational-algebra expression, we
provide a sequence of procedures that generates the
answer to our query.
• The tuple relational calculus, by contrast, is a
nonprocedural query language.
• It describes the desired information without giving a
specific procedure for obtaining that information.
• A query in the tuple relational calculus is expressed as

52
• {t | P(t)}
• i.e, it is the set of all tuples t such that predicate P is true
for t.
• Following our earlier notation, we use t[A] to denote the
value of tuple t on attribute A, and we use
• t ∈ r to denote that tuple t is in relation r.

53
Example Queries
• find the branch-name, loan-number, and amount for loans
of over $1200:
• {t | t ∈ loan ∧ t[amount] > 1200}
• Suppose that we want only the loan-number attribute,
rather than all attributes of the loan relation.
• To write this query in the tuple relational calculus, we
need to write an expression for a relation on the schema
(loan-number).
• We need those tuples on (loan-number) such that there
is a tuple in loan with the amount attribute > 1200.
• 54
• To express this request, we need the construct “there
exists” from mathematical logic.
• The notation
∃ t ∈ r (Q(t))
• means “there exists a tuple t in relation r such that
predicate Q(t) is true.”
• Using this notation, we can write the query “Find the loan number
for each loan of an amount greater than $1200” as
• {t | ∃ s ∈ loan (t[loan-number] = s[loan-number]
• ∧ s[amount] > 1200)}
55
• In English, we read the preceding expression as “The set
of all tuples t such that there exists a tuple s in relation
loan for which the values of t and s for the loan-number
attribute are equal, and the value of s for the amount
attribute is greater than $1200.”
• Tuple variable t is defined on only the loan-number
attribute, since that is the only attribute having a condition
specified for t.
• Thus, the result is a relation on (loannumber).

56
• For selecting both b_name and loan_no.
• {t | ∃ s ∈ loan (t[loan-number] = s[loan-number]
• ∧ t[b_name]=s[b_name] ^ s[amount] > 1200)}

57
• “Find the names of all customers who have a loan from
the Perryridge branch.”
• This query is slightly more complex than the previous queries,
since it involves two relations: borrower and loan.
• we shall require two “there exists” clauses in our tuple-relational-
calculus expression, connected by and (∧).
• We write the query as follows:
{t | ∃ s ∈ borrower (t[customer-name] = s[customer-name]
∧ ∃ u ∈ loan (u[loan-number] = s[loan-number ]
∧ u[branch-name] = “Perryridge”))}

58
• In English, this expression is “The set of all (customer-
name) tuples for which the customer has a loan that is at
the Perryridge branch.”
• Tuple variable u ensures that the customer is a borrower
at the Perryridge branch.
• Tuple variable s is restricted to pertain to the same loan
number as s.

59
• To find all customers who have a loan, an account, or
both at the bank, we used the union operation in the
relational algebra.
• In the tuple relational calculus, we shall need two “there
exists” clauses, connected by or (∨):
{t | ∃ s ∈ borrower (t[customer-name] = s[customer-name])
∨ ∃ u ∈ depositor (t[customer-name] = u[customer-name])}

60
• Find only those customers who have both an account and
a loan at the bank,
• all we need to do is to change the or (∨) to and (∧) in the
preceding expression.
• {t | ∃ s ∈ borrower (t[customer-name] = s[customer-
name]) ∧ ∃ u ∈ depositor (t[customer-name] =
u[customer-name])}

61
• “Find all customers who have an account at the bank but
• do not have a loan from the bank.”
• The tuple-relational-calculus expression for this query is
similar to the expressions that we have just seen, except
for the use of the not (¬) symbol:
{t | ∃ u ∈ depositor (t[customer-name] = u[customer-name])
∧ ¬ ∃ s ∈ borrower (t[customer-name] = s[customer-
name])}
This tuple-relational-calculus expression uses the ∃ u ∈
depositor (. . .) clause to require that the customer have an
account at the bank 62
• and it uses the ¬ ∃ s ∈ borrower (. . .) clause to eliminate
those customers who appear in some tuple of the
borrower relation as having a loan from the bank.

63
Formal Definition
• We are now ready for a formal definition.
• A tuple-relational-calculus expression is of the form
– {t | P(t)}
• where P is a formula.
• Several tuple variables may appear in a formula.
• A tuple variable is said to be a free variable unless it is quantified
by a ∃ (there exists) or ∀( for all) .
• Thus, in t ∈ loan ∧ ∃ s ∈ customer(t[branch-name] = s[branch-
name]) t is a free variable.
• Tuple variable s is said to be a bound variable.

64
Domain Relational Calculus
• A second form of relational calculus, called domain
relational calculus,
• uses domain variables that take on values from an
attributes domain, rather than values for an entire tuple.
The domain relational calculus, however, is closely
related to the tuple relational calculus.
• Domain relational calculus serves as the theoretical basis
of the widely used QBE language, just as relational
algebra serves as the basis for the SQL language.

65
Formal Definition
• An expression in the domain relational calculus is of the
form
• {< x1, x2, . . . , xn > | P(x1, x2, . . . , xn)}
• where x1, x2, . . . , xn represent domain variables.
• P represents a formula composed of atoms.
• An atom in the domain relational calculus has one of the
following forms:
• 1. < x1, x2, . . . , xn > ∈ r, where r is a relation on n
attributes and x1, x2, . . . , xn are domain variables or
domain constants. 66
• 2. x # y, where x and y are domain variables and # is a
comparison operator (<, ≤, =, =, >, ≥).
• We require that attributes x and y have domains that can
• be compared by #.
• 3. x # c, where x is a domain variable,
• # is a comparison operator,
• and c is a constant in the domain of the attribute for which
x is a domain variable.

67
Example Queries
• Find the loan number, branch name, and amount for loans of over
$1200:
• {< l, b, a > | < l, b, a > ∈ loan ∧ a > 1200}
• Find all loan numbers for loans with an amount greater than
$1200:
• {< l > | ∃ b, a (< l, b, a > ∈ loan ∧ a > 1200)}
• In the tuple calculus, when we write ∃ s for some tuple variable s,
we bind it immediately to a relation by writing ∃ s ∈ r.
• However, when we write ∃ b in the domain calculus, b refers not
to a tuple, but rather to a domain value.

68
• Find the names of all customers who have a loan from the
Perryridge branch and find the loan amount:
• {< c,a > | ∃ l (< c, l >∈ borrower ∧ ∃ b (< l, b, a > ∈ loan
∧ b = “Perryridge”))}
• Find the names of all customers who have a loan, an
account, or both at the Perryridge branch:
{< c > | ∃ l (< c, l >∈ borrower ∧∃b, a (< l, b, a >∈ loan ∧ b
= “Perryridge”)) ∨∃a (< c,a >∈ depositor ∧∃b, n (< a, b, n
>∈ account ∧ b = “Perryridge”))}
69
View Definition
• We define a view by using the create view statement.
• To define a view, we must give the view a name, and
must state the query that computes the view.
• The form of the create view statement is
create view v as <query expression>
• where<query expression>is any legal relational-algebra
query expression.
• The view name is represented by v.

70
• As an example, consider the view consisting of branches
and their customers.
• We wish this view to be called all-customer.
• We define this view as follows:
create view all-customer as
Π branch-name, customer-name (depositor account)
∪ Π branch-name, customer-name (borrower loan)

71
• Once we have defined a view, we can use the view name
to refer to the virtual relation that the view generates.
Using the view all-customer, we can find all customers of
the Perryridge branch by writing
Πcustomer-name (σbranch-name =“Perryridge” (all-
customer))
View names may appear in any place where a relation
name may appear, so long as no update operations are
executed on the views.

72
Views Defined by Using Other Views
• view relations may appear in any place that a relation name may
appear, except for restrictions on the use of views in update
expressions.
• Thus, one view may be used in the expression defining another
view.
• For example, we can define the view perryridge-customer as
follows:
create view perryridge-customer as
Πcustomer-name (σbranch-name =“Perryridge” (all-customer))
• where all-customer is itself a view relation.

73
74
Summary
• The relational data model is based on a collection of
tables.
• The user of the database system may query these tables,
insert new tuples, delete tuples, and update (modify)
tuples.
• There are several languages for expressing these
operations.
• The relational algebra defines a set of algebraic
operations that operate on tables, and output tables as
their results.
75
• These operations can be combined to get expressions
that express desired queries.
• The algebra defines the basic operations used within
relational query languages.
• The operations in relational algebra can be divided into
– Basic operations
– Additional operations that can be expressed in terms of the
basic operations
– Extended operations, some of which add further expressive
power to relational algebra
76
• The tuple relational calculus and the domain relational
calculus are nonprocedural languages that represent the
basic power required in a relational query language.
• The basic relational algebra is a procedural language that
is equivalent in power to both forms of the relational
calculus when they are restricted to safe expressions.

77
78
79
80

You might also like