Monday 15 March 2010

Subtable in mysql database? -


I have a small shop and I want to put my order in the database. For example:

Order number: 1

Products:

  • Apple, price: $ 2, amount: 2, total value: 4 $
  • Orange: Price: $ 2, Amount: 2, Total Value: 2 $
  • Banane, Price: $ 3, Amount: 1, Total Value: 3 $

Total value: 9 $

So now I have created a table in my database with 3 rows (serial number, product, total value)

But how can I do my list of all my products in my row in the "products" in my database Something like a Sbbet UL?

If you want to store and order the product in the database, you have to create three tables.

  Product ID name Price order ID date order_products id_order id_product amount  

This is a very easy schema, but it is an easy solution to start understanding < / P>

Example Data

  Product ID | Name | Price 1 | Apple | 1000 2 Orange | 2000  

order

  id | Date 1 |  Id_product | Zodiac 1 | 1 | 1 1 | 2 | 2  

Show all products

  Choose from products *  

Show Order # 1

< Choose pre-order from Order * Order where id = 1

Show all products by order 1

  Choose option from order_products on products p P. ID = op.id_product where op.id_order = 1  

how you see, the third table store relationship, and together you can get information about the products

< / Div>

No comments:

Post a Comment