Escolar Documentos
Profissional Documentos
Cultura Documentos
Sam Warmuth
Conceptual Schema
ER Diagram
Constraints
The visible constraints for the schema are
- The ‘name’ attribute of Artist must be unique.
- The ‘title’ attribute of Artwork must be unique.
- The ‘name’ attribute of Customer must be unique.
- An artist may have multiple works of art, but any given artwork cannot
have multiple artists
Implicit constraints
- ‘year’ and ‘age’ attributes of Artwork and Artist (respectively) must be
integer values that are smaller than the current year.
- The ‘price’ attribute of Artwork must be a nonnegative float value.
- The ‘dollars_spent’ attribute of Customer must be a nonnegative float.
Relational Schema
Microsoft Access Implementation
Artist
Artwork
Group
gname artwork_title
Religious David
Religious Transfiguration
Group
gname artwork_title
Abstract Guernica
Customer
Cust_likes
customer_name group_name
Splinter Abstract
Shredder Controversial
Splinter Religious
SQL Queries
1. List the name of each artist and the total number of pieces of art for that
artist, sorted by the artist name.
SELECT Artwork.artist_name, COUNT(*) AS number_of_pieces
FROM Artwork
GROUP BY Artwork.artist_name
ORDER BY Artwork.artist_name ASC;
Query1
artist_name number_of_pieces
Donatello 2
Leonardo da Vinci 3
Michelangelo 1
Pablo Picasso 1
Raphael 3
2. For each piece of sculpture, list the artist name and the asking price.
SELECT Artwork.title, Artwork.artist_name, Artwork.price
FROM Artwork
WHERE (Artwork.type_of_art = “Sculpture”);
Query2
3. Find the average amount of money all customers have spent in the gallery.
SELECT AVG(Customer.dollars_spent) AS Average_spent
FROM Customer;
Query3
Average_spent
361333333.333333
4. Find the name of the art group that is most popular among the customers.
SELECT TOP Cust_likes.group_name,
COUNT(Cust_likes.customer_name) AS pop
FROM Cust_likes
GROUP BY Cust_likes.group_name
ORDER BY pop DESC;
Query4
group_name pop
Religious 2
5. Pick one customer and list all of the art (s)he might be interested, including
the title, the year it was made, and its asking price.
SELECT Artwork.title, Artwork.year, Artwork.price
FROM Cust_likes, Artwork, Groups
WHERE (Cust_likes.customer_name = “April O’Neil”)
AND (Cust_likes.group_name = Group.gname)
AND (Groups.artwork_title = Artwork.title);
Query5