First time poster here and I apologise if its in the wrong forum, I dont know if this should be in the database or the Java forum. Basically I need help with my database structure and queries if possible. I have a database structure set-up as following with 3 tables - items, orders and an intersection table called OrderItem:
Items
-----
ID - PK - AI
Name - VARCHAR - 50
Value - DECIMAL - 10,2
Weight - INT - 11
Size - INT - 11
Orders
------
ID - PK - AI
TotalPrice - DECIMAL - 10,2
CanTotalInserted - INT - 11
BottleTotalInserted - INT - 11
CrateTotalInserted - INT - 11
DATE - DATETIME
OrderItem
---------
ID - PK - AI
OrderID - INT - 11
ItemID - INT - 11
Quantity - INT - 11
Value - DECIMAL - 10,2
The items table contains 3 items - bottle, crate and can which each have their own weight, value and size values. I have a Java application where a user is able to run a method called addItem which accepts 2 parameters - itemID and number where itemID is set to either 1, 2 or 3 (Can, Crate, Bottle) and number is the quantity added to the order. Im basically having trouble with the query of a) Creating an order,
In my OrderItem table I would like to see rows of something like this:
ID|OrderID|ItemID|Quantity|Value
--------------------------------
1 1 1 3 12
2 1 2 4 100
3 1 3 2 30
4 2 2 1 25
5 2 3 1 15
6 3 1 1 4
7 4 2 3 75
...and so forth.
Thanks in advance for any help provided, if you need me to clarify on any points let me know.

New Topic/Question
Reply




MultiQuote





|