0% found this document useful (0 votes)
5 views2 pages

Deebo 24007 Awsm: CS315: Principles of Database Systems, IIT Kanpur (23 Aug 2024) Name Roll No Dept

The document is a quiz for CS315: Principles of Database Systems at IIT Kanpur, containing instructions and questions related to SQL queries and database design. It includes tasks such as counting songs, retrieving artist information, identifying foreign keys, and designing primary keys. The quiz assesses knowledge on SQL syntax and database relationships using a provided gaana database schema.

Uploaded by

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

Deebo 24007 Awsm: CS315: Principles of Database Systems, IIT Kanpur (23 Aug 2024) Name Roll No Dept

The document is a quiz for CS315: Principles of Database Systems at IIT Kanpur, containing instructions and questions related to SQL queries and database design. It includes tasks such as counting songs, retrieving artist information, identifying foreign keys, and designing primary keys. The quiz assesses knowledge on SQL syntax and database relationships using a provided gaana database schema.

Uploaded by

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

CS315: Principles of Database Systems, IIT Kanpur Quiz I (23 Aug 2024)

Name DEEBO 20 marks


Roll No 24007 Dept. AWSM Page 1 of 2

Instructions:
1. This question paper contains 1 page (2 sides of paper). Please verify.
2. Write your name, roll number, department above in block letters neatly with ink.
3. Write your final answers neatly with a blue/black pen. Pencil marks may get smudged.
4. Don’t overwrite/scratch answers especially in MCQ – ambiguous cases may get 0 marks.
5. Hardcoding attempts will not get any credit.
6. Be extremely precise in your answers and be careful not to make spelling or punctuation mistakes. We may
type your answers as SQLite queries to actual DB and give marks based on how correct the retrieved results are.
The gaana database designed by our DB engineers Deebo and Deeba has 3 tables artist, album and song.
song.length is always a strictly positive integer. artist.aadhar_no is the artist’s Aadhar number and is
unique for every artist. album.id is a unique number given to every album by the music industry. An artist will
never release two albums with the same name, but albums by two different artists may have the same name. An
album will never contain two songs of the same name, but
artist
two different albums may contain songs with same name.
aadhar_no first_name last_name
2011-21 Teebo Totter song
name album_id length
1002-12 Melbo null name album_id length
Cun Cun 104 101
1911-11 Beeba Bopper Buk Buk 101 22
PoorPoor 105 11
1011-11 Kopi null Bok Bok 101 33
PaarPaar 105 2
9022-92 Ceebo Carnum Bak Bak 101 100
Tyt Tyt 106 56
album MunMun 102 25
Tot Tot 106 333
id album_title artist_id release_year Min Min 102 1
Tet Tet 106 222
101 B-Smash 1911-11 2024 MonMon 102 45
Tyt Tyt 107 99
102 M-Swing 1002-12 2022 Kob Kob 103 22
Tut Tut 107 2
103 B-Smash 1011-11 2024 Kub Kub 103 88
Tot Tot 107 42
104 C-Drow 9022-92 2022 Can Can 104 33
Tat Tat 107 111
105 A-Par 1011-11 2023 Con Con 104 55
106 Zing-T 2011-21 2023
107 T-Zing 2011-21 2023
Q1. Write an SQL query to help Deebo count the number of songs of length ≥ 100. (1 mark)
SELECT COUNT(*) FROM song WHERE length >= 100;
Alternatives such as using COUNT(name) are admissible (will receive full marks) but are riskier
in case the name column is NULL in certain rows.

Q2. Write a query to retrieve the Aadhar numbers of all artists without a last name. (2 marks)
SELECT aadhar_no FROM artist WHERE last_name IS NULL;
Please note that using the predicate “last_name = NULL” will not give intended results and such
solutions will receive only partial marks. The NULL value cannot be compared with using usual
comparison operators such as <> or = or !=
Page 2 of 2
Q3. (Foreign Relations) Deeba suspects certain columns might be foreign keys. Given are some
column names. If a column should be a foreign key, write the table and column it should reference
(i.e., its parent). If it shouldn’t be a foreign key, write “None” (don’t just leave blank). (4 marks)
Child Table.Column Parent Table Parent Column
song.album_id album Id

album.artist_id artist aadhar_no

album.album_title None None

album.id None None


Q4. (The Key to Success) Deebo wishes to design a primary key for the table album. Which of the
following combinations would work? Write Y/N for Yes/No. (4 marks)
Proposed Primary Key Y/N Proposed Primary Key Y/N
id Y album_title, release_year N

artist_id, release_year N album_title, artist_id Y


Q5. Write a query to retrieve name and album_id of songs from albums released in 2023. If two
songs released in 2023 have the same name, then that name should appear twice in the output.
Sort the output in increasing order of song length (song length is not to be retrieved). (4 marks)
SELECT name, album_id FROM song, album
WHERE song.album_id = album.id
AND album.release_year = 2023
ORDER BY song.length ASC;

Q6. Write a query to get aadhar_no and first_name of artists who have at least one song of
length ≥ 100. Artist details should not repeat if they have released multiple such songs.(5 marks)
It is possible to solve this problem in several ways e.g., using (correlated) nested queries.
However, simple joins (implicit or explicit) will also do the job and may be much faster.
SELECT aadhar_no, first_name
FROM artist, album, song
WHERE song.length >= 100
AND song.album_id = album.id
AND album.artist_id = artist.aadhar_no
GROUP BY artist.aadhar_no;

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