Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 21st, 2003, 04:02 PM
zapata zapata is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 96 zapata User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 19 h 36 m 16 sec
Reputation Power: 5
If similar "object", one more more tables?

Hello,

I have two questions about database design, that follow:

Question Number 1

if a database holDs several "objects" like:

- news (id, title, date, autor, text)
- articles (id, title, text)
- site text (id, title, text)

News holds "news" that appear in the frontpage;
Articles holds "articles" that appear in the articles section of the site;
Site text holds textual articles that belong to the site, like a credit/made by page, site presentation article and so on.

These things are very similar and only change on some of the info and the place they should be displayed.

What would be the best thing to do?

1- Have a single table with True/False fields (*)?
2- Have a table for each of those things?

* Something like:
- articles -
id
title
date
author
text
is_news T/F
is_text T/F

Then I would do:
- select * from articles where is_news = 0 and is_text = 0, to fecth the ARTICLES
- select * from articles where is_news = 1, to fetch the NEWS
- select * from articles where is_text = 1, to fetch the SITE TEXT.

Question Number 2

These articles can have more than one author. I just don't know how many it will be.

Would the following be a good way to solve this?

[ARTICLE]
article_id
...

[AuthorList]
id
article_id
author_id

[Author]
id
name

That is, having a table with W records. Each article could have several entries in the AuthorList table. I would then select all AuthorList records that have a certain value in "article_id" or "author_id" to get the list of authors for a given article or the list of articles by a given author.

Other ways to do this?

Thanks in advance.

Reply With Quote
  #2  
Old December 21st, 2003, 05:56 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,653 r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 6 Days 12 h 42 m 2 sec
Reputation Power: 981
question 1 -- yes, i would put them into one table, but not with a series of t/f fields, rather with a type code

question 2 -- yes, that is the best design for a many-to-many relationship, except you do not really need AuthorList to have its own id, just the two relationship ids

rudy

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > If similar "object", one more more tables?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway