
November 14th, 2003, 05:08 PM
|
|
Junior Member
|
|
Join Date: Nov 2003
Posts: 1
Time spent in forums: 2 m 14 sec
Reputation Power: 0
|
|
|
mysql db design question
There's one aspect of a small MySQL db I'm building that's confusing me and I'd like to ask about it. It's for a website that displays a series of articles on various subjects. PHP writes the articles and menus dynamically based on the contents of the db.
One table has the following columns:
article_id (primary key, auto increment)
title (for article title and title bar of browser title)
author (links to another table with info about author, such as first name, last name, some other biographical data...)
text (body of article)
theme (there are five submenu of articles. Each represents a particular theme)
source (first place of publication)
country (country of publication - may go with 'source' to a separate table)
date (date the article was written)
My question relates to the 'theme' column. There are currently 5 different themes. When the user clicks 'themes' in the main menu, the site links to a theme page where the five themes are listed. There, the user can click to go to a specific theme. On that page, I'll list all articles where that particular theme is indicated in the db.
2 of these themes also have subthemes. There are 4-6 subcategories of them that are also reflected on the webpage. So in those pages, I need to break down the list of articles into these subcategories. The other pages can just list all the relevant articles without further classification.
I could just add subtheme as a column in the db described above, but there'd be a lot of NULL entries. I'm not clear on what's a good, clean way to put together a table that deals with the subthemes. I need to be able query for the menus with subtheme breakdowns that gets all articles where theme=thisPageTheme and subtheme=thisSectionSubtheme, so the table must be set up accordingly.
I realize this isn't complex and there are a few ways to do it. But though I can come up with ideas that work, they don't feel right.
Anyone with more db design experience than me (I don't have much) have any ideas on how to address this?
|