title: Apply a not null constraint via a many-to-many relationship?
body: <p>I need to make sure that every project in my database has a contact person.  "projects" and "contacts" have a many-to-many relationship, specified in the table "projects_contacts".  Could I create a table constraint within projects that will specify the project must exist within the join table?  Or do I need to take a completely different approach?<br>
  (I need users to be able to manually enter contact data while in the middle of adding project data, so I'm worried that the NOT NULL will hang up their ability to create a project before there is a contact.)  </p>
  
  <p>Would this be better addressed in the build of the user interface?</p>
  
  <p>Thanks!</p>
  
  <pre><code>CREATE TABLE projects(
  id_project INTEGER PRIMARY KEY,
  description text)
  
  CREATE TABLE contacts(
  id_contact integer PRIMARY KEY
  firstname varchar(100) )
  
  CREATE TABLE projects_contacts(
  id_projects_contacts integer PRIMARY KEY,&gt;
  id_project integer,
  id_contact integer
  CONSTRAINT FOREIGN KEY project_fkey (id_project) REFERENCES projects ON UPDATE CASCADE ON DELETE CASCADE
  CONSTRAINT FOREIGN KEY contact_fkey (id_contact) REFERENCES contacts ON UPDATE CASCADE ON DELETE CASCADE)
  </code></pre>