2 Replies - 2005 Views - Last Post: 19 December 2012 - 03:55 PM Rate Topic: -----

#1 hwoarang69  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 171
  • Joined: 23-October 12

database structures

Posted 12 December 2012 - 01:35 AM

so iam create a ecommerce base site. where user can buy stuff. i need some help with coming up a good database structures. so far i got 5 tables.

here is what iam thinking:
"user" table to keep track of users
"user_info" table to keep there detial inforamtion
"billing" table if they want to buy a item
"item" table info about item
"cart" table - not sure about this one.

-------
user
-------
user_id
user name
password


-------
user_info
-------
user_info_id
user id
item_brought //int array?
first_name
last_name
dob

-----------
item
----------
item_id
item_name
item_des
...


--------
billing
-------
billing_id
user_id
email
area_code primary_phone
street_address
apt, suite, bldg.(optional)
zipcode
country
state
city

----------
cart
--------
cart_id
user_id
Quantity
color
size


let me know if i could add more tables or if there is a better way to create tables.

This post has been edited by hwoarang69: 12 December 2012 - 01:36 AM


Is This A Good Question/Topic? 0
  • +

Replies To: database structures

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,225
  • Joined: 08-June 10

Re: database structures

Posted 12 December 2012 - 04:03 AM

two things Id change: item_brought does not belong into the user_info table. Id rather make another table that links user_id and item_id. Id also put Quantity there. color & size of the cart table obviously belong into the item table (unless you mean the color and size of the cart, which IMO doesnt make sense). well, actually I think the cart table should become the above mentioned link table.

I also recommend to read Atlis Tutorial on DB design.
Was This Post Helpful? 1
  • +
  • -

#3 gonzaw  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 18-December 12

Re: database structures

Posted 19 December 2012 - 03:55 PM

Since user info is data about a user itself, I don't see why it should be a separate table.

Have a "user(user_id,username,password,first_name,last_name)" table instead.

An item bought by a user is a N to 1 relationship. I.e one user can buy N items, but one item can only be bought by one user.

It's not total though, i.e there can be items that aren't bought by an user, so create a new table like this:

"purchase(user_id,item_id)"

item_id is the primary key because it's a 1 to N relation thus an item can't be in that table twice (while a user can).

Basically what the above user said.

I don't really know how carts work so I can't help you with that one lol.

I assume the billing is the info about the purchase as well right? In that case I guess it can be added to the "purchase" table as well.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1