0% found this document useful (0 votes)
24 views7 pages

Relational Algebra

Relational Algebra

Uploaded by

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

Relational Algebra

Relational Algebra

Uploaded by

Suman Bhandari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 7
QO Bca nOTEs OO<¢ f. Secondary or Alternative key: Cokhara Leiversitey D The candidate key which are not selected as primary key are known as secondary keys or alternative keys. g. Non-key Attributes: Non-key attributes are the attributes or fields of a table, other than candidate key attributes/fields in a table. utes: Non-prime Attributes are attributes other than Primary Key attribute(s). h. Non-prime Att Structure of Relational Database: A relational database consists of a collection of tables, each having a unique name. Arrow ina table represents a relationship among a set of values. Thusa table represents a collection of relationships. There Is a direct correspondence between the concept of a table and the mathematical concept of a relation. A substantial theory has been developed for relational databases. Table also called Relation ry Key Seopa | 1 Google Active 2 Amazon Active ——Tuple OR Row 3 Apple Inactive Totel # of rows is Cerdinalty Column OR Attributes Total # of column is Degree Relation Algebra in DBMS Relational algebra is a procedural query language that works on relational model. The purpose of a query language is to retrieve data from database or perform various operations such as insert, update, and delete on the data. www.ckundan.com.np 8 QO Bcd nOTEs ) CProthara University, D Types of Relation Operation: Relational Operation 1. Select Operation: The select operation selects tuples that satisfy a given predicate. It is denoted by sigma (o). Notation: o p(r) Where, +g isused for selection prediction + risused for relation + p isused as a propositional logic formula which may use connectors like: AND OR and NOT. These relational can use as relational operators like =, #, 2, <,>,<. Example: LOAN RELATION BRANCH_NAME LOAN_NO | AMOUNT Downtown 1000 Redwood 2000 Perryride 1500 Downtown 1500 Mianus 500 Roundhill 900 Perryride 1300 Input: @ BRANCH NAMES"persyride" (LOAN) ES www.ckundan.com.np 9 QOBCa NOTES VQ) Prettara BtuivorsityD ‘Output: BRANCH_NAME LOAN_NO | AMOUNT Perryride 15 1500 Perryride L-16 1300 2. Project Operation: ‘This operation shows the list of those attributes that we wish to appear in the result. Rest of the attributes are climinated from the table. It is denoted by []. Notation: [] A1, A2, An (r) Where, Al, A2, A3 is used as an attribute name of relation r. Example: CUSTOMER RELATION NAME | STREET | CITY Jones Main Harrison Smith North Rye Hays Main ‘Harrison Curry North Rye Johnson Alma Brooklyn Brooks Senator Brooklyn Input: f)Naue, crry (custoneR) Output: NAME _| CITY Jones Harrison Smith Rye Hays Harrison Cuny | Rye Johnson | Brooklyn Brooks | Brooklyn www.ckundan.com.np 10 QO Bcd nOTEs ) CProthara University, D 3. Union Operation: Suppose there are two tuples K and S. The union operation contains all the tuples that are cither in R or S or both in R&S. It eliminates the duplicate tuples. It is denoted by U. Notation: RUS Aunion operation must hold the following condition: + Rand S must have the attribute of the same number. + Duplicate tuples are eliminated automatically. Example: DEPOSITOR RELATION CUSTOMER.NAME ACCOUNT_NO Johnson A101 ‘Smith ALL Mayes A321 Turner A176 Johnson A273 Jones MATZ Lindsay A284 BORROW RELATION CUSTOMER.NAME_LOAN_NO Jones Lay ‘Smith 1-23 Hayes Ls, Jackson Las Curry L-93 ‘Smith Ll Williams LAT Input: Tl customer same (BORROW) U [| CUSTOMER WANE (DEPOSTTOR| Output: CUSTOMER NAME Johnson Smith Hayes SS www.ckundan.com.np i QOBCa NOTES OO Pokhara Luiversity) Turner Jones Lindsay Jackson curry Williams Mayes 4. Set Intersection: ‘Suppose there are two tuples R and S. The set intersection operation contains all tuples that are in both R & S. Itis denoted by intersection n. Notation: RAS Example: Using the above DEPOSITOR table and BORROW table Input: fl ctistoMen NAME (BORROW ff] CUSTONER NAME’ (DEPOSTTOR) Output: CUSTOMER_NAME ‘Smith Jones 5. Set Difference: Suppose there are two tuples R and S. The set intersection operation contains all tuples that are in R but notin S, [tis denoted by intersection minus (-). Notation: R-S Example: Using the above DEPOSITOR table and BORROW table www.ckundan.com.np QOBCa NOTES (MQ Preetara DtuiversityD HicustoMen, same (BORROW) = [] CUSTOMER NAME! (DEPOSTTOR) Output: CUSTOMER_NAME Jackson Hayes Willians Curry 6. Cartesian Product: ‘The Cartesian product is used to combine each row in one table with each row in the other table. Itis also known as a cross product. It is denoted by X. Notation: EXD Example: EMPLOYEE RELATION EMP_ID EMP_NAME EMP_DEPT 1 Smith A 2 Harry c 3 Jobn B DEPARTMENT RELATION DEPT.NO_DEPT_NAME a Marketing B Sales c Legal Input: Output: EMP_ID_|_EMP_NAME EMP_DEPT DEPT.NO_DEPT_NAME 1 si A A Marketing 1 Smith A B Sales www.ckundan.com.np 1 Q 6c A NOTES ) Pokhara luiversityD 1 ‘Smith A Cc Legal 2 Harry Cc A Marketing 2 Harry c B Sales 2 Harry Cc Cc Legal 3 John B A Marketing 3 John B B Sales 3 Jobn B c Legal 7. Rename Operation: ‘The rename operation is used to rename the output relation. Itis denoted by rho (p). Notation: p(New Relation Name, Old Relation Name) Example: We can use the rename operator to rename STUDENT relation to STUDENT1. p(STUDENT1, STUDENT) Relational Calculus: Relational calculus is a non-procedural query language. In the non-procedural query language, the user is concerned with the details of how to obtain the end results. The relational calculus tells what to do but never explains how to do. Types of Relational calculus: a= = caleulas 1. Tuple Relational Calculus (TRC): ‘The tuple relational calculus is specified to select the tuples in a relation, In TRC, filtering variable uses the tuples of a relation. The result of the relation can have one or more tuples. www.ckundan.com.np 14

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy