Você está na página 1de 6

COEN 4810 – Database Applications

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

aname birthplace age style

Leonardo da Vinci Piza 557 Renaissance

Donatello Florence 623 Renaissance

Raphael Rome 526 Renaissance

Michelangelo Arezzo 534 Renaissance

Pablo Picasso Malaga 128 Cubism

Artwork

title year_created artist_name type_of_art price

David 1504 Michelangelo Sculpture 400000000

The Mass at Bolsena 1512 Raphael Painting 13000000

Mona Lisa 1505 Leonardo da Vinci Painting 1000000000

The Last Supper 1498 Leonardo da Vinci Painting 1000000000

Virtruvian Man 1485 Leonardo da Vinci Sketch 500000000

St. Mark 1413 Donatello Sculpture 10000000

Mary Magdalene 1455 Donatello Sculpture 10000000

Galatea 1512 Raphael Painting 3500000

Transfiguration 1520 Raphael Painting 1750000

Guernica 1937 Pablo Picasso Painting 5000000

Group

gname artwork_title

Religious David

Religious St. Mark

Religious Transfiguration
Group

gname artwork_title

Abstract Guernica

Controversial Mary Magdalene

Controversial The Last Supper

Customer

cname address dollars_spent

April O'Neil 322 E 5th, NY 30000000

Splinter Underneath Central Park 54000000

Shredder Foot Clan HQ 1000000000

Cust_likes

customer_name group_name

April O'Neil Religious

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

title artist_name price

David Michelangelo 400000000

St. Mark Donatello 10000000

Mary Magdalene Donatello 10000000

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

title year_created price

David 1504 400000000

St. Mark 1413 10000000

Transfiguration 1520 1750000

Você também pode gostar