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 > entity relationship diagram question

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-17-02, 02:08
Rashad Rashad is offline
Registered User
 
Join Date: May 2002
Posts: 2
entity relationship diagram question

how do you represent many different kinds of essentially the 1 object? like a candidate for election, say, candidates can have a party, can be independant and so on...do i make 1 candidate entity and give it all possible attributes? or do i make many canidate entitys to represent all possibilities?
Reply With Quote
  #2 (permalink)  
Old 05-17-02, 07:54
Manish Manish is offline
Registered User
 
Join Date: Dec 2001
Location: Delhi/Bangalore, India
Posts: 74
Generally, having a schema representing an entity to have any one of a given set of attributes is not considered good ER-design. (because that's not how intuitive object-oriented systems work, in real world).

An alternative solution is to have an attribute (boolean) "Independent" associated with the Candidate, and an attribute "Party" associated too. The value in attribute "Party" is used only if the attribute "Independent" indicates the candidate belongs to a party.
__________________
manish
Reply With Quote
  #3 (permalink)  
Old 05-17-02, 12:28
fallacy fallacy is offline
Registered User
 
Join Date: May 2002
Posts: 24
actually, you are introducing a useless column there by having both an "independant" and "party" column. being "independant" can be considering being part of a "party" - the independant party.

those are mutually exclusive properties. it's the same as saying a candidate cannot be in two different parties at the same time.

i would personally model that one as a lookup value - a foreign key to a list of parties a candidate can belong to, listing independant as one of the possible parties.

in other words "party" and "indepedent" are the same attribute so should be the same column.
Reply With Quote
  #4 (permalink)  
Old 05-17-02, 12:46
Manish Manish is offline
Registered User
 
Join Date: Dec 2001
Location: Delhi/Bangalore, India
Posts: 74
Quote:
Originally posted by fallacy
actually, you are introducing a useless column there by having both an "independant" and "party" column. being "independant" can be considering being part of a "party" - the independant party.
I know, and I considered that while writing the above post. But keeping it this way would allow for any future expansions on logical/db-programming part (as per my experience has been with the programming part...), so it might be better to have as "component"-ized a design as it could be.

Anyway, this particular thing doesn't matter.... It was used as an example, and Rashad might want to utilize the concept onto other actual tables.
__________________
manish
Reply With Quote
  #5 (permalink)  
Old 05-17-02, 12:57
fallacy fallacy is offline
Registered User
 
Join Date: May 2002
Posts: 24
i guess i can't really see how it would allow for future logical expansion? will, in this particular situation anyways.

interestingly enough, my experience has taught me that keeping things completely relational and using lists where possible is a good thing =)

hehehe, such opposing experiences eh
Reply With Quote
  #6 (permalink)  
Old 05-17-02, 13:26
Manish Manish is offline
Registered User
 
Join Date: Dec 2001
Location: Delhi/Bangalore, India
Posts: 74
Maybe I read Object-Oriented concepts a bit too much.
__________________
manish
Reply With Quote
  #7 (permalink)  
Old 05-18-02, 06:02
Rashad Rashad is offline
Registered User
 
Join Date: May 2002
Posts: 2
thanks guys, this has been most helpful...
Reply With Quote
  #8 (permalink)  
Old 05-20-02, 16:53
Tone-A Tone-A is offline
Registered User
 
Join Date: May 2002
Location: USA
Posts: 1
Try to verbalize the real world facts you are modeling.

"Candidate may be associated with Party". Also true are instances where Candidate is not associated with a party. You can imply this by the lack of relationship between the two instances, (making it a nullable relationship, or zero-or-one to many) or you can introduce a unary fact, "Candidate is independent" with a true/false value.

Physically, a DBA may want to collapse those two facts into one, by making the lack of affiliation to a party one of the values in the party. Carefull though, there are parties out there now called 'The Independent Party', etc.
Reply With Quote
Reply

Thread Tools
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