DBMS (Unit 2) Notes
DBMS (Unit 2) Notes
DBMS (Unit 2) Notes
We know how to find the names of all customers with a loan in the bank:
Πcustomer -name (borrower )
We also know how to find the names of all customers with an account in the bank:
Π customer -name (depositor )
We need the union of these two sets; that is, we need all customer names that appear in
either or both of the two relations. We find these data by the binary operation union,
denoted, as in set theory, by ∪. So the expression needed is
Π customer -name (borrower ) ∪ Πcustomer -name (depositor )
Set Intersection
Suppose there are two relations R and S. The set intersection operation contains all
tuples that are in both R & S.
It is denoted by intersection ∩.
Suppose that we wish to find all customers who have both a loan and an account. Using
set intersection, we can write
Π customer -name (borrower ) ∩ Πcustomer -name (depositor )
Set Difference:
Suppose there are two relations R and S. The set intersection operation contains all
tuples that are in R but not in S.
It is denoted by intersection minus (-).
Notation: R - S
Cartesian product
The Cartesian product, also referred to as a cross-join, returns all the rows in all the
tables listed in the query. Each row in the first table is paired with all the rows in the
second table. This happens when there is no relationship defined between the two
tables.
It is denoted by X.
Aggregate function
{t| P(t)}
Output-
Find the loan number for each loan of an amount greater or equal to 10000
{t| P(t)}
Find all data of account having balance greater than or equal to 9000
Output-
Find account number of account having balance less than 9000 amount
1)Query to display the last name of those students where age is greater than 30
2)Query to display the last name of those students where age is greater than 27
3) Query to display all data of those students where age is greater than 27
{< account number, branch name, balance > | < account number, branch name, balance > ∈ Account
∧ (balance > 7000)}
Find the account number, branch, balance of accounts of greater than 7000 amount.
Find the loan number, branch, amount of loan having amount greater than 150 amount
{< loan number, branch name, Amount > | < loan number, branch name, Amount > ∈ Loan ∧
(Amount ≥ 150)}
Find the loan number for each loan of an amount greater or equal to 150
{< loan number> | branch name, Amount < loan number, branch name, Amount > ∈ Loan ∧
(Amount ≥ 150)}
Find the branch name for each loan of an amount greater than 90
{< branch name > | loan number, Amount < loan number, branch name, Amount > ∈ Loan ∧
(Amount>90)}
For R=(A,B,C) & let r1,r2 both be relations on schema R. Give the expression in
both tuple relational calculus and domain relational calculus that is equivalent
to relational algebra
i) A,B(r1)
TRC-{ t.A,t.B | r1(t)}
ii) B=19(r2)
TRC- {t|t ∈ (r2) ^ t[B]=19}
iv) r1n r2
TRC- {t|t ∈ r1 n t ∈ r2}
DRC- {<A,B,C> | <A,B,C> ∈ r1 n <A,B,C> ∈ r2 }
v) r1-r2
TRC- {t|t ∈ r1 ¬ t ∈ r2}
DRC-{<A,B,C> | <A,B,C> ∈ r1 ¬ <A,B,C> ∈ r2 }
Storage-device hierarchy
Primary Storage
Main Memory
Cache Memory
Secondary Storage
Flash Memory
Magnetic Disk Storage
Tertiary Storage
Optical Storage
Tape Storage
Storage Hierarchy Cost Decreases
Access time Increases
INDEXING
It is a data structure technique which allows you to quickly retrieve
records from a database file.