The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

How to avoid null?

I have following scenario-I need to record what school a user prefers in different locations.The user can choose none also.
Now,my table structure is LocationID,SchoolID.
To record that user has chosen none, I can have another column like SchoolChosen(1 or 0)and allow SchoolID to be null..can there be another solution?
jam
Tuesday, September 05, 2006
 
 
Assuming Location is an attribute of School:

1) Create a USER table, with a PK column called "Id".
2) Create a LOCATION table with a PK column called "Id".
3) Create a SCHOOL table with a PK column called "Id" and a FK column of LocationId pointing at the LOCATION table.

Then finally create a UserSchool table with 2 FK columns, UserId and SchoolId. For each preference, create a row in this table. The absence of rows in this table for a specific User means that user hasn't expressed a preference.
Mark Pearce Send private email
Tuesday, September 05, 2006
 
 
thks for the idea
jam
Tuesday, September 05, 2006
 
 
+1 for Mark.

Although, why are you trying to avoid null in the first place?
Almost H. Anonymous Send private email
Tuesday, September 05, 2006
 
 
Database design 101 saves the day!
KC Send private email
Tuesday, September 05, 2006
 
 
"why are you trying to avoid null in the first place? "

Thanks, it was a long day, I needed that.
D in PHX Send private email
Wednesday, September 06, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz