0% found this document useful (0 votes)
20 views3 pages

DB Lab 1

DATABASE LAB ASSIGNMENT

Uploaded by

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

DB Lab 1

DATABASE LAB ASSIGNMENT

Uploaded by

Abdulrahman Saif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Name: Muhammad Awais

Reg no: SP23-BCT-008

DATA
BASE

Db lab
Assignment no 1
Instructor: Sadia Maryam
Date: 29th Sep 2024
QUESTION # 1:

Q1: Write Relational algebra expressions for the following information needs
over Database Systems the Complete Book -Exercise 2.4.1(Note: you can use
similar queries from the given quires

Querying Database using Relational Algebra

i. List of PC models greater than 1000 and HD greater than 250.


ii. List of PC model, ram, HD and Price where model should be greater than
1000 and HD should be greater than 250.
iii. Find Maker, Model, Type, Speed, Ram and Price of Laptops which are
released after the year 2000, have a Price more than 1000 and have a Speed
greater than 1.5.
iv. List of product maker, PC model, ram, HD and price. Where model should be
greater than 1000 and HD should be greater than 250 and maker should not
be ‘B’.
v. Find the Speed of Laptops and PCs.
vi. List the Models of all the Laptops and PCs that have the same speed.
vii. List the Model and Maker of all the Laptops who have Model > 2005.
viii. List Product Model along with their Product Maker of all the Products with a
Speed greater than 1.5.
ix. List Model of all the Products that are released after 2000, have a Speed
greater than 1.5, and that belong to Laptop Type.
x. Find the total PC and their average speed for each Ram (512, 1024, 2048).

a) Πmodel(σmodel>1000∧hd>250(PC))
b) Πmaker, model, type, speed, ram, price(σyear>2000∧price>1000∧speed>1.5
(Laptop⋈Product))
c) Πmaker, model, ram, hd, price(σmodel>1000∧hd>250∧maker=′B′
(PC⋈Product))
d) speed(PC)∪Πspeed(Laptop)
e) ΠLaptop.model(σLaptop.speed=PC.speed(Laptop×PC))
f) Πmaker, model(σmodel>2005(Laptop⋈Product))
g) Πmodel, maker(σspeed>1.5(Product⋈(PC∪Laptop)))
h) Πmodel(σyear>2000∧speed>1.5∧type=′Laptop′(Laptop⋈Product))
i) γram,COUNT(model),AVG(speed)(PC)
Question 2:
- Write Relational algebra expressions for the following information
needs over University Database:

I. Retrieve the title of the course that is pre-req of 'Database System Concepts.’
II. Retrieve the semester and the year in which ‘Einstein’ taught the course
‘Physical Principles’.
III. Retrieve the ID and the title of all courses taken by ‘Shankar’ in ‘Fall 2009’.
IV. List the name of students who did not take any course in ‘Fall 2009’.
V. Find building, room number, and capacity of all classrooms in which student
‘Tanaka’ took all his classes.

1. π_title(σ_course_id='Database System Concepts' ∧


prereq.course_id=course.course_id (Prereq ⨝ Course))
2. π_semester, year(σ_name='Einstein' ∧ title='Physical Principles' (Instructor ⨝ Teaches
⨝ Course))
3. π_ID, title(σ_name='Shankar' ∧ semester='Fall' ∧ year=2009 (Student ⨝ Takes ⨝

4. π_name(Student) - π_name(σ_semester='Fall' ∧ year=2009 (Student ⨝ Takes))


Course))

5. π_building, room_number, capacity(σ_name='Tanaka' (Student ⨝ Takes ⨝ Section ⨝


Classroom))

You might also like