If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Subtype/supertype help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-20-06, 10:26
photo312 photo312 is offline
Registered User
 
Join Date: Jul 2006
Location: Fort Lauderdale, Florida
Posts: 2
Subtype/supertype help

Hi,

I have so far created 2 tables:

ITEM
---------
ITEM_ID ( PK )
ITEM_NAME
ITEM_DESCRIPTION
ITEM_COST
ITEM_CATEGORY ( 1=package, 2=product, 3=service )


PACKAGE
-----------
ITEM_ID ( PK, FK ITEM.ITEM_ID )
SUBITEM_ID ( PK, FK ITEM.ITEM_ID )
QUANTITY

This way, I can have a table PACKAGE where I can record packages that can contain 0 or more services and/or 0 or more products from the ITEM table.

Is this a good solution? My next suggestion was to create table for each entity: PRODUCT, SERVICE, PACKAGE.

But how would I create the table PACKAGE so that it stores 0 or more PRODUCT(S) and/or 0 or more SERVICE(S).

Thanks
Reply With Quote
  #2 (permalink)  
Old 07-21-06, 07:43
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by photo312
Is this a good solution?
i think so
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 07-22-06, 12:32
zkenet zkenet is offline
Registered User
 
Join Date: Jan 2004
Location: Toronto
Posts: 33
Question

There is no reason to split the ITEM table, the ITEM_CETAGORY column should do fine.

However, your description was a bit hard to follow... Are you trying to describe that packages can each have multiple items? If so, you want :

Package (PACKAGE_ID (PK), QUANTITY….)
Item (ITEM_ID (PK), PACKAGE_ID (FK), ITEM_NAME, ITEM_DESCRIPTION, ITEM_COST...)

Hence for every single package you can add multiple items (or no items at all). I may have very well misunderstood your requirements though.
Reply With Quote
  #4 (permalink)  
Old 07-22-06, 15:39
photo312 photo312 is offline
Registered User
 
Join Date: Jul 2006
Location: Fort Lauderdale, Florida
Posts: 2
Item table cannot have package id in there, because most items will not be part of any package....
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On