If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Bad design of CMS article tables?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-13-05, 13:13
googly googly is offline
Registered User
 
Join Date: Feb 2005
Posts: 15
Bad design of CMS article tables?

As part of the PHP/MySQL Content Management System which I'm constructing I have an article table which houses all of my articles and all of its components such as images etc. In addition to this I have a pages table which contains the content for all articles which have more than one page. I have a feeling that my table design isn't as good as it could be. Could anyone suggest improvements to what I have below please?

For instance at the moment I have the first page of the article in article table because most articles only have one page. The rest of the article's pages are in the pages table, is this a mistake?

article Table
Fields
article_id
writer
subject
headline
subheading
keywords
description
article_text
picture1
picture2
picture3
created
modified
published

pages Table
page_id
article_id
pagenum
pagetitle
pagecontent
Reply With Quote
  #2 (permalink)  
Old 02-13-05, 13:18
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
no, it's not a mistake, but it's more complicated than it needs to be

use just one table, and have page 2 link to page 1

of course, this begs the question of whether there needs to be a page 2 in the first place

i would let the front end decide where to split an article into pages

might have a totally different cutoff point for smaller devices, for example
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-13-05, 13:40
googly googly is offline
Registered User
 
Join Date: Feb 2005
Posts: 15
I think I understand what you mean. But if I had, for example, all the 4 pages of the article in the article table I may have a problem with the article_id field because at the moment it is the primary key of the article table.

Doesn't the first part of your suggestion mean that with each page of the article, the article_id would have to have the same value. Is there a good way to get around this?
Reply With Quote
  #4 (permalink)  
Old 02-13-05, 14:16
ByteRyder52 ByteRyder52 is offline
Registered User
 
Join Date: Feb 2005
Location: Colorado Springs
Posts: 222
Do you intend for this to be a "flat" table? It seems to me that list tables might be helpful. For example, a KeyWord table that can be linked to your article table via an intermediary table. Perhaps the same with authors (if there is more than one author per article).
Reply With Quote
  #5 (permalink)  
Old 02-13-05, 14:36
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by googly
...if I had, for example, all the 4 pages of the article in the article table I may have a problem with the article_id field because at the moment it is the primary key of the article table.
well, like i said earlier (and i repeat for emphasis now), it might be a better idea not to have "pages" at all, just articles -- one article, one row -- then your front end could decide where to split an article into pages

but if you must have pages, yes, then the combination (article_id,page_no) would be the primary key
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On