|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > If similar "object", one more more tables? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|