Should I create a seperate table?
Posted on 2004-08-29
I have a MySQL db that I use to create and store invoices. I currently have one field for hardware and one for hardware text. So I manually total the price of the hardware and then enter it. My script then adds the tax and adds the labour cost to create the total.
I have decided that this isnt good enough. I want to be able to enter a qty, description, and cost per unit for each item.
So would it be better to create a new table for hardware containing fields id, invoiceid, qty, description, unitcost
or just add say qty, description, unitcost : qty2, description2, unitcost2 : qty3, description3, unitcost3 etc.... to the current invoice table. Obviously this method limits the amount of peices of hardware to the amount of fields ive created but it would be easy to do.
If I create a new table, how should i be thinking about entering each hardware item? I guess my form would have to have 3 fields to enter each hardware item, but can i submit that part of the form and then create another set of text fields for the next item? Or should I create enough text fileds for a certain amount of items (say 10)?
And how would I be able to submit a hardware item that has the invoiceid if the invoice hasnt been created yet? Should I create an invoice, then have another page to add hardware to it?
Any suggestions would be great,