Monday, February 23, 2009

HW #4 Discussion

I'm working on HW #4 and just want to see if I am on the right track.

The first part of the HW says to create schema's for

menuItem(id, name, description, cost);
order(id, ordernum, itemid);

Now, I'm taking this to mean create 2 tables named 'menuItem' and 'order' with the following columns and given primary keys 'id.'

Am I on the right track?

Other folks may use this thread for hw #4 discussion as well : )

6 comments:

Yawo said...

They should be different ID's. I think they are just not labeled the right way. And also the way I understand it is that the primary key in menuItem table is a foreign key in order table as itemID.

Nicole Anderson said...

You should create two tables based on the schemas given. Each has their id as their primary key.

Clay Smith said...

Ok, and Yawo is correct in having the itemid in the order table be a foreign key to the id in the menuitem table?

Anonymous said...

Also, what would the difference between orderID and orderNum? wouldn't there really only need to be one of those?

Clay Smith said...

My guess is that orderID would be the auto-inc primary key, whereas orderNum would be the number of orders taken for the given itemID. OrderNum will probably reflect the number of french fries ordered, for instance.

Nicole Anderson said...

Attribute itemid is a foreign key to id in the menuItem table. Attribute id in the order table is the primary key and identifies a row. Attribute ordernum is for one order that may contain multiple items. So a burger, fries, and coke may all have the same ordernum but they will have different ids. All small french fries will have the same id in the menuItem table (small fry will be a single row).