150 likes | 217 Views
LEGO COLLECTION DATABASE. Monica Ham Assignment 5 SLIS 511. Project Description
E N D
LEGO COLLECTION DATABASE Monica Ham Assignment 5 SLIS 511
Project Description The goal of this project is to design an database for a family of Lego set collectors. Some collectors have so many sets they have trouble remembering details about all the sets they have. Another problem faced by collectors is losing track of assembly manuals. This database will help collectors to keep better track of the sets they own. Also who bought which set when, and how much they paid for it. Information about the minifigures that come with each set and assembly manuals will also be included.
MINIFIG M ER Diagram (1,1) 1 (0,N) SET 1 1 (0,N) (1,1) purchases 1 M BUYER (1,N) REBUILDS (1,1)
Query 1: List all sets owned ordered by theme. select theme AS "Theme", setname AS "Set Name" from set order by theme ASC, setname ASC;
Query 2: List number of sets from the Harry Potter theme that are part of the collection select count(*) from set where theme='Harry Potter';
Query 3: List names of distinct mini figures (collectors may have many repeat minifigures). select distinct minifigname from minifig;
Query 4: List all sets and the buyer/owner of each set SELECT set.setname, buyer.buyername, purchaseyear FROM set FULL JOIN buyer ON set.set_id=buyer.set_id ORDER BY buyername ASC;
Query 5: List the rebuilds associated with each set name and organize by theme. SELECT set.theme, set.setname,rebuilds.rebuildname, set.digitalmanual, rebuilds.manualpart FROM set RIGHT JOIN rebuilds ON set.set_id=rebuilds.set_id ORDER BY theme ASC, setname ASC;
Query 6: List total amount of money spend on Lego sets by each buyer. SELECT buyername,SUM(pricepaid) FROM buyer GROUP BY buyername;
Query 7: List the number of sets purchased and the total amount spent on those sets by year. SELECT purchaseyear, count(distinct set_id) AS "number of sets", SUM(pricepaid)AS "total expenditure" FROM buyer GROUP BY purchaseyear;
Query 8: List all minifigures of humans and their associated sets in alphabetical order. SELECT minifig.minifigname, set.setname FROM minifig INNER JOIN set ON minifig.set_id=set.set_id WHERE minifig.minifigtype='human' ORDER BY set.setname ASC, minifig.minifigname ASC;
Query 9: List the set name and price of sets that cost more than the average set cost. SELECT set.setname, buyer.pricepaid FROM set INNER JOIN buyer ON set.set_id=buyer.set_id WHERE buyer.pricepaid>(SELECT avg(pricepaid) FROM buyer);
Query 10: List the name of each buyer/owner and the percent of the collection they own. SELECT buyername, count(*) * 100 / (SELECT count(*) FROM buyer) AS "percent" FROM buyer GROUP BY buyername;
Query 11: List sets that have rebuilds and their associated themes. SELECT DISTINCT set.setname, set.theme FROM set RIGHT JOIN rebuilds ON set.set_id=rebuilds.set_id ORDER BY theme ASC, setname ASC;