Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to create a database that has several customers and many orders per each customer and each order has several items in it. I was thinking of creating a table for each order and populate each order from an "items" table, but this solution seems cumbersome after you reach thousands of orders and will be pretty hard to query. Any suggestions? Your help is greatly appreciated.

share|improve this question

closed as too broad by Nifle, terdon, Shakehar, Excellll, Journeyman Geek Jul 27 '13 at 12:56

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

    
What is your database BTW? –  Nikolay Jul 17 '13 at 22:19
    
@Nikolay I am planning to use sqlite, but since I just picked up database design(I am currently learning to program) I am playing around with Microsoft Access to get to know this stuff a little bit better. –  edferda Jul 17 '13 at 22:27
    
Cool. MS Access should have wonderful graphic designer which will allow you to link your tables in graphical mode. You will see lines between tables showing how exactly your tables related to each other. In this video ... approximately on minute 3 and so on ... they show how to link tables together. I did not watch it, but I think it can give you good start. –  Nikolay Jul 17 '13 at 22:31
    
Maybe you can have a table with an order number, customer id, items, quantity, and some identifier, and simply select all values with an order number? Sounds like one of those cases where cracking open a textbook would help. –  Journeyman Geek Jul 27 '13 at 13:00

1 Answer 1

up vote 0 down vote accepted

You can have table which keeps your customers. You can have table which keeps orders. You can have table which keeps items per order. Just link them correctly with foreign keys and it should work for you.

Table one has filed ID and field name.

Table two has field ID and field customer (which refers to ID of first table)

Table three has field ID, field ORDER (which refers to ID of second table) and field items (which can refer to ID of another table - ITEMS).

Not necessary it should be exactly like that - this is just general concept for you.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.