Docsity

Five Basic Operators, Cartesion Product - Database Management - Lecture Slides, Slides of Introduction to Database Management Systems

Partial preview of the text

Download Five Basic Operators, Cartesion Product - Database Management - Lecture Slides and more Slides Introduction to Database Management Systems in PDF only on Docsity!

Database

Management

System

Lecture - 17

Five Basic Operators

Unary Operators

1.Select

2.Project

Select

Selects tuples that satisfy a given

predicate

Notation is Greek symbol sigma:

σ PREDICATE ( RELATION)

Select

To process a selection,

  • Look at each tuple
  • See if we have a match (based on the

condition)

Selection Example

stId stName stAdr prName curSem

S1020 Sohail Dar H#14, F/8- 4,Islamabad.

MCS 4

S1038 Shoaib Ali H#23, G/9- 1,Islamabad

BCS 3

S1015 Tahira Ejaz H#99, Lala Rukh Wah.

MCS 5

S1018 Arif Zia H#10, E-8, Islamabad.

BIT 5

Selection Example

  1. σ (^) Curr_Sem > 3 (STUDENT)
  2. σ (^) Studid = ‘S1038’ (STUDENT)

Selection

Example Cont’d)

1. σ Salary > 27000 (FAC)

2. σ(Salary>26000) and (Rank=‘Asso Prof’) (FAC)

Projection

Unary operation that returns its

argument relation with certain

attributes left out.

Any duplicate rows are

eliminated.

Projection

Works on a single relation R and

defines a relation that contains a

vertical subset of R, extracting the

values of specified attributes and

eliminating duplicates.

Projection

Reduces duplicate columns

created by cross product.

 Creates a New relation

Projection Example

 π FacID, Salary (Faculty)

 π Fname, Rank (Faculty)

 π Facid, Salary,Rank (Faculty)

Union

Assuming R & S are union

compatible…

Union: R ⋃ S is the set of tuples

in either R or S or both.

Union Example

C2345 P1245 3 Operating Sytems C3456 P1245 4 Database Systems C4567 P9873 4 Financial Management C5678 P9873 3 Money & Capital Market

CID ProgID Cred_Hrs CourseTitle

C4567 P9873 4 Financial Management C8944 P4567 4 Electronics

CID ProgID Cred_Hrs CourseTitle

Course

Course

Union Example

C2345 P1245 3 Operating Sytems

C3456 P1245 4 Database Systems

C4567 P9873 4 Financial Management

C5678 P9873 3 Money & Capital Market

CID ProgID Cred_Hrs CourseTitle

C8944 P4567 4 Electronics

Course 1 U Course 2