How would I structure this?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
nado
Forum Newbie
Posts: 20
Joined: Tue Aug 29, 2006 3:47 am

How would I structure this?

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
nado
Forum Newbie
Posts: 20
Joined: Tue Aug 29, 2006 3:47 am

Post 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


?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
nado
Forum Newbie
Posts: 20
Joined: Tue Aug 29, 2006 3:47 am

Post 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)?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Yep, that's the general idea.
Post Reply