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 is ArtistId said to be a "foreign key"?

2.2 (2 points)

In the table called Album, there’s a column called AlbumId and a column called ArtistId, but in the table called Artist, there’s only a column called ArtistId. Why does the table called Artist not have a column called AlbumId?

2.3 (2 points)

Even if every customer has a unique email address, why might you nonetheless want to use an INTEGER like CustomerId as the PRIMARY KEY for Customer?

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 is 50?

2.6 (2 points)

In the table called Track is a column called Composer that contains quite a few duplicate values. Propose how to eliminate that inefficiency in no more than two sentences.

Debrief

  1. Which resources, if any, did you find helpful in answering this problem’s questions?

  2. About how long, in minutes, did you spend on this problem’s questions?