This is a simple question for seasoned vets, but I am new to database programming.
I have a table for cake orders and a table for cupcake orders. I had to split the two because the table columns are completely different (e.g., I have different requirements for the different orders).
However, I want each order to have a unique order_ID. If the first order was a cake, I want it to be 100; and then if the next order is a cupcake, I want it to be 101, not 100, etc.
I thought about creating an all_orders table that just keeps a running tab of the orders and when a new cake order comes in it adds a new entry into all_orders and puts the order_ID from all_orders into the cake table's order_ID column.
Tables:
cakes
--------
order_ID
amount
type
(etc.)
cupcakes
--------
order_ID
amount
type
(etc.)
all_orders
----------
order_ID
cake_or_cup
Is that the best way to do this?
Max
I have a table for cake orders and a table for cupcake orders. I had to split the two because the table columns are completely different (e.g., I have different requirements for the different orders).
However, I want each order to have a unique order_ID. If the first order was a cake, I want it to be 100; and then if the next order is a cupcake, I want it to be 101, not 100, etc.
I thought about creating an all_orders table that just keeps a running tab of the orders and when a new cake order comes in it adds a new entry into all_orders and puts the order_ID from all_orders into the cake table's order_ID column.
Tables:
cakes
--------
order_ID
amount
type
(etc.)
cupcakes
--------
order_ID
amount
type
(etc.)
all_orders
----------
order_ID
cake_or_cup
Is that the best way to do this?
Max