Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


how best to create tables

how best to create tables

how best to create tables

I am trying to come up with a database plan for a product database.

We need to store

product info such as name, price, description, product category (each can be in multiple categories), manufacturer
a list of available categories
product images
manufacturer info

How is best to structure this in a database so that it will be efficient (and easier to code haha) to input, store and link this info? Here's what I am thinking...

Product (basic product info)

manufacturer (link to manufacturer table > id)

Category list (list of available categories)

category name

Product categories (each product can have multiple categories so this is to link the two)

productid (link to product table > id)
categoryid (link to product table > id)

Product images (each product can have lots of images)

image name
image file
productid (link to product table > id)

Manufacturer table


is that about right or would you folks do it better?

I will be creating a php page with text input, textareas for the info areas, dropdown for the manufacturer and checkboxes for the categories to add all of this data.

It will be displayed on an internal webpage where users can search through categories, manufacturers, price etc.


RE: how best to create tables

you are clearly on the right track

however, i would eliminate the "id" column in the product categories table, and assign the pair of FKs as the PK

i would also eliminate the "id" column in the product images table, and assign the PK as productid plus image name

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon

RE: how best to create tables

Thanks, I suppose I didn'tneed the ID's on those tables.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close