| Author |
Topic |
|
X-Factor
Constraint Violating Yak Guru
392 Posts |
Posted - 2004-11-29 : 09:05:29
|
| Hi,I have a table which contains the data for a news stories. Each row in the table contains the text for one news story.There needs to be a list/menu of news stories down the left side of the page. Kind of like a list of categories that one might find on an e-commerce site. The list needs to be orderable too. i.e. a user can assign an integer ordinal to a news story which determines its position in the list relative to other news items.The situation I have is that there is a second table which stores the menu items. Each and every menu item is linked to one and only one news item. A menu item has a reference to its parent menu item and also has a column for the above mentioned ordinal.Now, I think that this second table is unnecessary. All of the data in the menu items table could be associated with the appropriate news story in the actual news story table. All its doing is spliting entities into two seperate tables.Any thoughts? |
|
|
X-Factor
Constraint Violating Yak Guru
392 Posts |
Posted - 2004-11-29 : 09:10:59
|
| So instead of...NewsItems=========NewsItemID int pkname varchar(50)MenuItems=========menuItemID int pkNewsItemID int fkordinal intparentID int fkshouldn't it be...NewsItems=========NewsItemID int pkname varchar(50)ordinal intparentID int fk |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-11-29 : 10:12:07
|
i don't see the point of using two tables for the example you described.maybe they wanted for one story to have two parents or two childern or something like that?Go with the flow & have fun! Else fight the flow |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2004-11-29 : 12:54:59
|
| NewsItems and MenuItems are not the same thing.They are separate entities and I think they are right in storing them in different tables.rockmoose |
 |
|
|
X-Factor
Constraint Violating Yak Guru
392 Posts |
Posted - 2004-12-02 : 08:09:37
|
quote: They are separate entities and I think they are right in storing them in different tables.
Yes I agree. One might decide that a news item should not appear in the menu so it would better to be able to just delete the menu item rather than have the news item padded with null menu data. |
 |
|
|
X-Factor
Constraint Violating Yak Guru
392 Posts |
Posted - 2004-12-02 : 08:15:38
|
| However, having said that, isn't having a table of menu items an instance of failing to distinguish between presentation and content? |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-12-02 : 08:33:16
|
Not at all, in fact it is confirming that separation. You're treating the actual news items and how they are presented on a menu as separate but related entities.Like anything else, too much of a good thing (separation of application layers) is bad. If this structure works for you then keep it, even if it violates some programming principle. Hell, I'm sure it violates a couple of normal forms too, and lightning didn't strike you down, did it? |
 |
|
|
X-Factor
Constraint Violating Yak Guru
392 Posts |
Posted - 2004-12-02 : 09:20:29
|
| Thanks for your reply.Which normal forms do you think this violates? Surely if news items and menu items are independent entites and they're in seperate tables there's little room for normalization errors. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-12-02 : 09:39:28
|
| "Violate" is probably the wrong term, and I was not suggesting there was anything wrong with your table design. I meant to say that there is always some extreme degree of a design principle (multi-tier, normalization, etc.) that is not worth the effort needed to achieve it. Worrying about "doesn't this violate so-and-so" is fruitless if your design works for you and you have no problems with it, practical, logical, or otherwise. |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2004-12-02 : 13:53:32
|
quote: Originally posted by robvolk "Violate" is probably the wrong term, and I was not suggesting there was anything wrong with your table design. I meant to say that there is always some extreme degree of a design principle (multi-tier, normalization, etc.) that is not worth the effort needed to achieve it. Worrying about "doesn't this violate so-and-so" is fruitless if your design works for you and you have no problems with it, practical, logical, or otherwise.
Sounds almost like a Carte Blanche to disregard any design principle that one feels fit!rockmoose |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-12-02 : 14:00:04
|
| I don't know where you got that from, and that's not what I meant either. |
 |
|
|
|