SQLiTunes
Recall the database from Week 8 whose tables represented a digital media store.
And recall that you can download files (e.g., lecture.db
) into CS50 IDE with wget
.
Answer the below in sqlitunes.md
. (Note: If you downloaded the Quiz before 5:45pm on Sat 4/21, rename the downloaded sqlite.md
file to sqlitunes.md
) before trying to submit.
Questions
- 2.1 (1 point)
-
In the table called
Album
, why isArtistId
said to be a "foreign key"? - 2.2 (2 points)
-
In the table called
Album
, there’s a column calledAlbumId
and a column calledArtistId
, but in the table calledArtist
, there’s only a column calledArtistId
. Why does the table calledArtist
not have a column calledAlbumId
? - 2.3 (2 points)
-
Even if every customer has a unique email address, why might you nonetheless want to use an
INTEGER
likeCustomerId
as thePRIMARY KEY
forCustomer
? - 2.4 (2 points)
-
With what single SQL statement could you select only the total (i.e., aggregate) amount of money spent by customers in 2010?
- 2.5 (3 points)
-
With what single SQL statement could you select only the names of all tracks (i.e., songs) ever purchased by Enrique Muñoz, whose
CustomerId
is50
? - 2.6 (2 points)
-
In the table called
Track
is a column calledComposer
that contains quite a few duplicate values. Propose how to eliminate that inefficiency in no more than two sentences.
Debrief
-
Which resources, if any, did you find helpful in answering this problem’s questions?
-
About how long, in minutes, did you spend on this problem’s questions?