Professional Documents
Culture Documents
Developed by : Ms. Nita Arora Kulachi Hansraj Model School Ashok Vihar
Relational Algebra
Selection Projection Union Cartesian Product
What is a database?
A database is a collection of related data elements
Tables (entities) Columns (fields or attributes) Rows (records)
DBMS Architecture
Usually taken to imply a three level architecture. The complexity of a large database is handled by a DBMS by providing three views of the data.
An internal view of how the data is stored and accessed A conceptual view of what data is available in the database. Local or external views which are a limited and simplified view of the database as suitable for a single application or group of associated applications.
View 1
View 2
View 3
View 4 etc.
Conceptual Level
Physical Data Independence
Conceptual Schema
Internal Level
Internal Schema
One of the fundamental aspects of the database approach using a DBMS is that, by providing levels of data abstraction, it hides complexity of data storage from users.
Terminology
Terminology
(Contd.)
Relational Algebra
The relational algebra is a collection of operations on relations. Each operation takes one or more relations as operand and produces another relation as its result
Relational Algebra
Operations defined in relational algebra include :
Select Project Cartesian Product Union * Set difference * Set intersection * Natural join * Division
Select
Project
Join
Builds a relation from two specified relations consisting of all possible concatenated pairs, one from each of the two relations, such that in each pair the two tuples satisfy some condition. (E.g., equal values in a given col.)
A1 B1 A2 B1 A3 B2 B1 C1 B2 C2 B3 C3 (Natural or Inner) Join A1 B1 C1 A2 B1 C1 A3 B2 C2
Outer Join
Outer Joins are similar to PRODUCT -but will leave NULLs for any row in the first table with no corresponding rows in the second.
Outer Join A1 A2 A3 A4 B1 B1 B2 B7 B1 C1 B2 C2 B3 C3
A1 B1 C1 A2 B1 C1 A3 B2 C2 A4 * *
Join Items
Invoice # Part # Quantity 93774 3 10 84747 23 1 88367 75 2 88647 4 3 776879 22 5 65689 76 12 93774 23 10 88367 34 2
Cust #
Part # 1 2 3 4 5 6 7 8 9
Name Price Count Big blue widget 3.76 2 Small blue Widget 7.35 4 Tiny red widget 5.25 7 large red widget 157.23 23 double widget rack 10.44 12 Small green Widget 30.45 58 Big yellow widget 7.96 1 Tiny orange widget 81.75 42 Big purple widget 55.99 9
STREET2 Floor 12 CITY New York Phildelphia Cyberoid Nashua Middletown Sagrado Rivendell Orinda Suite 882 Compton STATE NY PA NY NH IN TX CA CA CA ZIPCODE 02111 03756 08645 09242 32467 78798 93456 94563 95328
Rep # 3 4 5 9 2 6 1 1 2 1 2 2
3 Cyber Associates General 4 Consolidated Consolidated 5 MultiCorp Internet Behometh 6 Ltd. Consolidated 7 Brands, Inc. 8 Little Mighty Micro 9 SportLine Ltd.
34 Bureaucracy Plaza Floors 1-172 3 Control Elevation Cyber Assicates Place Center 35 Libra Plaza 1 Broadway 88 Oligopoly Place 3 Independence Parkway 34 Last One Drive 38 Champion Place