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 > General > Database Concepts & Design > Orders table design question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-29-06, 09:30
subfocus subfocus is offline
Registered User
 
Join Date: Mar 2006
Posts: 1
Orders table design question

Hi there, I'm trying to create a simple shop database, which can hold the following info...
  • Products
  • Customer details
  • Orders

I can't seem to get my head around how I can store more than one product_id (and its quantity) in a orders record without using another table.

So I'd have a orders table, with a order_id for each record, which would be linked to a orderdetails table. Each record in the orderdetails table would hold the order_id it was for, the product_id and quantity ordered.

I hope this makes sense to someone as I'm a bit confused now .

Any advice would be great - thanks.
Reply With Quote
  #2 (permalink)  
Old 03-29-06, 11:21
ByteRyder52 ByteRyder52 is offline
Registered User
 
Join Date: Feb 2005
Location: Colorado Springs
Posts: 222
Yes, you would need an order detail table that has a M:1 relationship with order.
Reply With Quote
  #3 (permalink)  
Old 03-29-06, 16:32
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,797
And, since you could order more than one product in a given order, you should also add a line number field in the order details table.

The PK for the order details would then be the order ID AND the Line Number.

The order ID would be a FK to the orders table...the part number would be a FK to the parts table.
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Reply With Quote
  #4 (permalink)  
Old 04-07-06, 15:57
bdimple bdimple is offline
Registered User
 
Join Date: Jul 2003
Posts: 74
Here's a relevant Data Model

[QUOTE=subfocus]Hi there, I'm trying to create a simple shop database, which can hold the following info...

This Data Model might help to clarify your thinking :-
http://www.databaseanswers.org/data_...ders/index.htm

The same site lists many Customer-related Data Models :-
http://www.databaseanswers.org/data_models/index.htm

HTH

B.Dimple
Senior DBA
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