Best way to set up these tables...?

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
Matt
Forum Newbie
Posts: 2
Joined: Mon May 06, 2002 5:12 pm

Best way to set up these tables...?

Post by Matt »

Best table structure for a table that organizes items by category, subcategory1, subcategory2, subcategory3
I was thinking there would be the category name and id table, eg

cat_id,cat_name
1, teen
2, college girls
3, mature women

and a subcategory table, eg

sub_cat_id, sub_cat_name
1, busty
2, athletic
3, blonde
4, brunette
etc.

and then the item table

women_id, name, age
1,anna, 19
etc.

Since it's possible to have multiple subcategories, I would need a 4th table that would hold all the relationships.

cat_id, sub_cat_id, women_id
1,1,1
1,2,1
1,3,1

My concern is that this 4th table that everything hinges isn't based on a primary key and can get quite huge.

Is this the optimal way to solve this problem?
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

^_^

Post by phice »

id,type,bodytype,name,age

1,teen,athletic,anna,19
2,mature women,busty,jenny,95

4 tables, into 1. ;)
Image Image
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Good idea having the categories as foreign keys - less typing less chance of spelling mistakes - but you don't need a table full of them just add them into the item (women are items?) table:

Code: Select all

woman_id  name  age  cat1 cat2
---------------------------------
1         anna   19    1    1
Mac
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

twigletmac wrote:(women are items?)
:oops:
Image Image
User avatar
Crashin
Forum Contributor
Posts: 223
Joined: Mon May 06, 2002 3:42 pm
Location: Colorado

Post by Crashin »

Me likes the sounds of the site YOU'RE developing! :D
Post Reply