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 > probably a newbie question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-17-07, 13:56
vitriol vitriol is offline
Registered User
 
Join Date: Dec 2007
Posts: 2
Question probably a newbie question

I'm in the process of planning my first big database. I'm using MySQL. The database will keep track of inventory, orders, and production for our coffee roastery.
I have a table called Coffees, and one called Customers. Each of these has a one to many relation with a table called Orders. An order consists of several kinds of coffee, the amount of each of those coffees, and a customer.
I'm stumped about how to reference multiple coffees in an order, and keep a quantity associated with each coffee.
As I write this it dawns on me that this might be a time to use SET or ARRAY, but that's beyond my current know-how. Any advice?
The only thing I've thought of is making each record in Orders describe a single coffee and amount ordered, then let the front-end collate all records with the same date and customer into a complete order.
Thanks for your time & help.
Reply With Quote
  #2 (permalink)  
Old 12-17-07, 14:04
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
this is just like the classic customers-orders-products design, except you have coffees instead of products

- Coffee table should describe each coffee
- Customers table should describe each customer
- Orders table should describe each order, with FK to Customers
- OrderCoffees should have one row per coffee per order (so the PK is a composite key of order_id and coffee_id), with Qty as the data column
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 12-17-07, 14:08
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Coo - do you gather, store & reference customer details in your coffee shop?
Reply With Quote
  #4 (permalink)  
Old 12-17-07, 14:39
vitriol vitriol is offline
Registered User
 
Join Date: Dec 2007
Posts: 2
thanks!

of course! thanks for the quick answer.

Regarding our coffee shops, no we don't store customer data, but I think we should. I even went through the trouble of deploying a fancy client-server app to do it, but the store managers felt it was too time consuming to actually have to type in customer's info.
The present project is to manage our wholesale production and sales, along with web-based orders. https://secure.joevangogh.com is our online store if you're interested.
Reply With Quote
  #5 (permalink)  
Old 12-17-07, 16:40
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Heh - that makes more sense. Ta!
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