Relational Algebra

Topics: Relational model, Relational algebra, Relation Pages: 32 (3731 words) Published: January 27, 2013
RELATIONAL ALGEBRA
Query Language
It is a Language in which a user request information from the database. These languages are typically of a level higher than that of the standard programming language. It is divided into either procedural or non-procedural language. In the procedural Language, the user instructs the system to perform the sequence of operation on the database to compute a desired result. In a non-procedural Language, the user describes the information desired without giving a specific procedural for obtaining the information.

Relational Algebra Definition
It is a procedure language. It consists of a set of operations that take one or more relations as input and produce a new relation as a result. The fundamental operations of relational algebra are select, project, union, set difference, Cartesian product and rename. Other operations are: Set intersection, natural join, division and assignment. • The basic set of operations for the relational model is known as the relational algebra. These operations enable a user to specify basic retrieval requests. • The result of retrieval is a new relation, which may have been formed from one or more relations. The algebra operations thus produce new relations, which can be further manipulated using operations of the same algebra. • A sequence of relational algebra operations forms a relational algebra expression, whose result will also be a relation that represents the result of a database query (or retrieval request).

Keys
• Let K ( R where K is a superkey of R if values for K are sufficient to identify a unique tuple of each possible relation r(R) – by “possible r” we mean a relation r that could exist in the enterprise we are modeling. – Example: {customer-name, customer-street} and

{customer-name}
are both superkeys of Customer, if no two customers can possibly have the same name. • K is a candidate key if K is minimal
Example: {customer-name} is a candidate key for Customer, since it is a superkey (assuming no two customers can possibly have the same name), and no subset of it is a superkey.

Determining Keys from E-R Sets
• Strong entity set. The primary key of the entity set becomes the primary key of the relation. • Weak entity set. The primary key of the relation consists of the union of the primary key of the strong entity set and the discriminator of the weak entity set. • Relationship set. The union of the primary keys of the related entity sets becomes a super key of the relation. – For binary many-to-one relationship sets, the primary key of the “many” entity set becomes the relation’s primary key. – For one-to-one relationship sets, the relation’s primary key can be that of either entity set. – For many-to-many relationship sets, the union of the primary keys becomes the relation’s primary key

E-R diagrmam
[pic]
Account Relation
[pic]

The depositor Relation
[pic]
The customer Relation
[pic]

The Loan relation
|Branch name |Loan number |amount | |Downtown |L-17 |1000 | |Redwood |L-23 |2000 | |Perryridge |L-15 |1500 | |Downtown |L-14 |1500 | |Mianus |L-93 |500 | |Round hill |L-11 |900 | |Perryridge |L-16 |1300 |

The Borrower Relation...