Archived

This topic is now archived and is closed to further replies.

Database Question

This topic is 4956 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What is a good way to represent Either/Or relationships. Say you have a Truck object. The truck can either by owned by an individual or a company but not both. Right now I am using two booleans and if one is true the other MUST be false. Sitting here writing this I guess a single boolean would work. On = individual, off = company. Assuming an item can not have no owner, which would certainly be possible... Would be nice to have the functionality of radio buttons in a database. Anyone got a clean way of achieving this? Thanks, Webby

Share this post


Link to post
Share on other sites
you could always just have it be some kind of short int field where values correspond to types of owners (perhaps you will add more types of owners later).

this would correspond to an enumeration on the code side, and you can certainly have radio buttons on databases, just write a nice PHP or JSP/Java app with which to populate your database.

-me

Share this post


Link to post
Share on other sites
This is true and is what I will switch to. Very good point about adding new owners. Some things seem so cut and dry at first, they you get a second opinion.

Thanks,
Webby

Share this post


Link to post
Share on other sites