Page 1 of 1

How would I structure this?

Posted: Tue Sep 05, 2006 7:43 am
by nado
hi

I'm new to PHP/MYSQL...

I've currently setup a simple database for customers (just adds a unique id, name, email etc for each customer).

But now I'm looking into PayPal IPN stuff where the data gathered is sent back and stored in the database.

At this stage I don't particularly want to do much with the data, I just figured it might be an idea to store it for later use (when I do hire a developer to setup a proper ecommerce store)

What I'm wondering is how you setup something like this:

- customer 1
--- order
--- order
- customer 2
--- order

etc

Is there a particular way to store data in this way or is it just a matter of matching up an id or email and then just displaying them in a certain way?

cheers
nathan

Posted: Tue Sep 05, 2006 8:17 am
by feyd
customer table, order table, order line item table, etc. Line items point to the product, price the customer paid, quantity requested and of course the order they belong to. Orders could contain a subtotal, taxes, and some other bits, but mostly they simply point to the customer id they belong to.

Posted: Tue Sep 05, 2006 8:40 am
by nado
I'm still not sure what you mean.

Is it like:

Customer table row:

id (cust) | name | email | etc

Order table row:

id (cust) | id (order) | item | price | etc


?

Posted: Tue Sep 05, 2006 8:54 am
by feyd
Three tables: customer, order, order line item

Code: Select all

customer -< order -< order line item
where -< is a one-to-many relationship.
nado wrote:Order table row:

id (cust) | id (order) | item | price | etc
This is more of a description for an order line item table.

Posted: Tue Sep 05, 2006 9:21 am
by nado
Yep I'll only be using a simple system.

But is that how you link the different tables? .... i.e. give the customer row a unique id and you copy this id to an order row (to that customer's order)?

Posted: Tue Sep 05, 2006 9:36 am
by feyd
Yep, that's the general idea.