Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 1-1 Relationship

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 pk
name varchar(50)

MenuItems
=========
menuItemID int pk
NewsItemID int fk
ordinal int
parentID int fk

shouldn't it be...

NewsItems
=========
NewsItemID int pk
name varchar(50)
ordinal int
parentID int fk
Go to Top of Page

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
Go to Top of Page

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
Go to Top of Page

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.
Go to Top of Page

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?

Go to Top of Page

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?
Go to Top of Page

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.
Go to Top of Page

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.
Go to Top of Page

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
Go to Top of Page

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.
Go to Top of Page
   

- Advertisement -