Lab Assignment 2 DBMS
Lab Assignment 2 DBMS
SEC: C
TITLE: ASSIGNMENT 01
SUBMITTED ON : 17 / 10 / 2024
TABLE OF CONTENTS
ASSIGNMENT 01 ........................................................................................................................................ 3
GIVEN RELATIONS: .............................................................................................................................3
TASK 1: ............................................................................................................................................... 3
List the year and title of each book: ...................................................................................3
Query: ........................................................................................................................................ 3
Justification: .......................................................................................................................................4
TASK 2: ............................................................................................................................................... 4
List all information about students whose major is CS. ..................................................... 4
Query: ........................................................................................................................................ 4
........................................................................................................................................................... 4
Justification: .......................................................................................................................................5
TASK 3: ............................................................................................................................................... 5
List all books published by McGraw-Hill before 1990. .......................................................5
Query: ............................................................................................................................................... 5
........................................................................................................................................................... 5
Justification: .......................................................................................................................................6
TASK 4: ............................................................................................................................................... 6
List all students with the books they can borrow. ............................................................. 6
Query: ............................................................................................................................................... 6
Justification: .......................................................................................................................................7
TASK 5: ............................................................................................................................................... 7
Rename AuthorName in AUTHORS relation to Name. ...................................................... 7
Query: ............................................................................................................................................... 7
Justification: .......................................................................................................................................8
TASK 6: ............................................................................................................................................... 8
List the names of all students who have borrowed a book ............................................... 8
and who are CS majors. .............................................................................................................8
Query: ............................................................................................................................................... 8
Justification: .......................................................................................................................................9
TASK 7: ............................................................................................................................................... 9
List each book with its keywords ........................................................................................9
Query: ............................................................................................................................................... 9
Justification: .....................................................................................................................................10
TASK 8: ............................................................................................................................................. 10
List the title of books written by the author ‘Elmasri’. .................................................... 10
Query: ............................................................................................................................................. 10
Justification: .....................................................................................................................................11
TASK 9: ............................................................................................................................................. 11
List the authors of the books the student ‘Sultan’ has borrowed. .................................. 11
Query: ............................................................................................................................................. 11
Justification: .....................................................................................................................................12
TASK 10: ...........................................................................................................................................12
Rename AuthorName in AUTHORS relation to Name. .................................................... 12
Query: ............................................................................................................................................. 12
Justification: .....................................................................................................................................13
ASSIGNMENT 01
GIVEN RELATIONS:
TASK 1:
List the year and title of each book:
Query:
π Title,Year(BOOKS)
Justification:
We are using it here to get just the Title and Year of the
BOOKS.
TASK 2:
List all information about students whose major is CS.
Query:
It will return all the details ( ID, name, and major e.t.c) but
only for the student that have major “CS”
TASK 3:
List all books published by McGraw-Hill before 1990.
Query:
σPublisher=′McGraw−Hill′∧Year<1990 (BOOKS)
Justification:
This query will return all books that meet both conditions.
TASK 4:
List all students with the books they can borrow.
Query:
STUDENTS ⋈ BORROWS
This query returns both the StdName and the BookId of books
they have borrowed.
TASK 5:
Rename AuthorName in AUTHORS relation to Name.
Query:
TASK 6:
List the names of all students who have borrowed a book
and who are CS majors.
Query:
This query returns both the StdName and the BookId of books
they have borrowed.
TASK 7:
List each book with its keywords.
Query:
This ensures that only the titles of the books and their
keywords are displayed, while other details will be excluded.
The result shows each book along with the keywords that
describe it.
TASK 8:
List the title of books written by the author ‘Elmasri’.
Query:
This connects Authors with the books they have written by linking
AuthorName and BookId.
This ensures that we only look at the records related to the author
'Elmasri'.
This means we only want to see the Titles of the books written by
'Elmasri', without other details
TASK 9:
List the authors of the books the student ‘Sultan’ has borrowed.
Query:
The final result lists the AUTHORS for the books that 'Sultan'
has borrowed.
TASK 10:
Rename AuthorName in AUTHORS relation to Name.
Query:
⋈
σ Keyword = ′programming′ (DESCRIBES))
Justification:
This finds all records of books that have the keyword 'database'.
This connects the books that have the KEYWORD 'database' with
those that have the keyword 'programming'.
This means we only want to see the IDs of the books that have
both keywords.
The final result lists the IDs of books that have both the
KEYWORDS 'database' and 'programming'.