MySQL Forums
Forum List  »  Newbie

Database Structure Question
Posted by: Tim Whitaker
Date: March 28, 2016 12:06AM

I am building my first website using MySQL and PHP. And I am having trouble getting my arms around the database table design.

Content heavy site...local search engine for a specific business sector.

I will have ~8-10 main categories in the navigation with 200+ subcategories.

What I am struggling with is some of the listings will fit in multiple subcategories (or more)??

Keeping things simple for questions sake...
Table 1: a "listings" table with all the information for each listing...with primary key listingID.

Table 2 & 3: A category and subcategory table with primary keys categoryID and subcategoryID.

Where I am struggling is should I have two additional tables to cross-reference each listing with their associated category and subcategory? (i.e. tables that are simply listingID, subcategoryID) If so, these would be cross-reference tables with two foreign keys and no primary key that is necessary which doesn't seem correct.

Putting a listingID in the category and subcategory table would blow it out substantially and defy any normalization logic which is why I am thinking I need those two cross-reference tables.

Am I thinking about this correctly or is there a better way?

Thanks in advance for helping a database design noob...

Tim

Options: ReplyQuote


Subject
Written By
Posted
Database Structure Question
March 28, 2016 12:06AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.