title: What is best way to use NHibernate to map a constrained many-to-many relationship?
body: <p>I have two entities represented by two tables in the database, joined by a linking table with a unique constraint on each of the two foreign keys. (See this <a href="https://stackoverflow.com/questions/6886934/what-is-the-best-way-to-represent-a-constrained-many-to-many-relationship-within">question</a> for details). The linking table allows for a many-to-many relationship, but the unique constraint ensures that there is only a one-to-one relationship in practice.</p>
  
  <p>A good analogy to the problem is cars and parking garage spaces. There are many cars and many spaces. A space can contain one car or be empty; a car can only be in one space at a time, or no space (not parked).</p>
  
  <p>We have a Cars table and a Spaces table and the linking table called Parking. Here is the linking table:</p>
  
  <pre><code>create table parking (
    car_id references car,
    space_id references space,
    unique car_id,
    unique space_id
  );
  </code></pre>
  
  <p>Is there a way to map this relationship in NHibernate such that each entity holds a single property representing the related entity, rather than a collection?</p>