views:

48

answers:

2

Hello,

I have relation 0..1 to N, for example between drivers and cars. So one driver can be assigned to many car, but one car to many drivers. However I want to have possibility of assigning no driver to car. So should I have field which allow nulls and has null as default value for this field? If so, then what value should I have in dropdown (I use asp.net mvc) for deleting assosiation?

A: 

What's wrong with using zero?

Patrick
Just a style, I was always (PHP time) using null for no reference.
Inez
A: 

One driver can be assigned to many cars and one car can be assigned many drivers. Create association table (CarsDrivers) with CarId and DriverId (only two fields). Update model from database and you'll have one EntityCollection in Car (containing assosiated drivers) and second EntityCollection in Driver (containing assosiated Cars). If you want no Driver assosiated with Car, keep collection empty. What is the problem? Did you actually try doing that?

LukLed