24
Assignment 5 S511 – Database Design Fall 2012 Anna Alfeld

Assignment 5 S511 – Database Design Fall 2012 Anna Alfeld

Embed Size (px)

Citation preview

Assignment 5

S511 – Database DesignFall 2012

Anna Alfeld

Project Description

I am an avid crafter and over the past several years I have created dozens of gift- or greeting-type cards using a variety of materials. Most of the cards are centered around a poem or quote. I use a variety of rubber stamps, inks and powders to decorate them. The goal of this project is to design a database to record the materials used in each card so I can create more cards.

Definitions

Entities: Card: An individual hand-made greeting-type card

identified by the poem on the inside. Stamp: A rubber stamp used with ink and powder to

create an image. There are two kinds of stamps: Wood-mounted Cling

Ink : The colored fluid used for stamping an image. There are two types of inks:• Pigment• Archival

More entities… Powder: The powder that is sprinkled on the stamped

image and melted. There are two types of powder:• Opaque• Transparent

Object: An individual instance of a stamped image on a card. Every card can have one or more objects. Every object uses one stamp, one ink and one powder.

ER Diagram

Business Rules

• Each card has one or more objects; each object is on only one card.

• Each stamp can be used on one or more objects; each object uses only one stamp.

• Each powder can be used on one or more objects; each object uses only one powder.

• Each ink can be used on one or more objects; each object uses only one ink.

Tables

More Tables

Table: Card

Table: Ink

Table: Object

Table: Powder

Table: Stamp

Query 1.select object_id, ink_brand, ink_color from cards.object, cards.ink where object.ink_id=ink.ink_id;

Query 2.select poet, poem, stamp_name, object_id from cards.card, cards.stamp, cards.object where object.card_id=card.card_id and object.stamp_id=stamp.stamp_id and stamp.product_line='Mindscapes';

Query 3.select poet, poem, stamp_name, object_id, powder_color from cards.card, cards.stamp, cards.object, cards.powder where object.card_id=card.card_id and object.stamp_id=stamp.stamp_id and object.powder_id=powder.powder_id and powder.product_line='PEARLustre';

Query 4select card.poem, card.poet, stamp.stamp_name, ink.ink_color from object, card, stamp, ink where object.card_id=card.card_id and object.stamp_id=stamp.stamp_id and object.ink_id=ink.ink_id and stamp.product_line='Mindscapes';

Query 5select count(*), poet from card group by card.poet;

Query 6.select poet, poem, quantity from card where quantity>(select avg(quantity) from card);

Query 7.select * from card where height>width order by font;

Query 8.select object_id, poet, poem, stamp_name, ink_color, powder_color from object, card, stamp, ink, powder where card.poet= (select card.poet from card where card.poet='Emily Dickinson' and object.card_id=card.card_id and object.stamp_id=stamp.stamp_id and object.ink_id=ink.ink_id and object.powder_id=powder.powder_id);

Query 9.select object_id, poet, poem from object left join card on object.card_id=card.card_id;

Query 10.select object_id, poet, poem from object right join card on object.card_id=card.card_id order by card.poet;