title: PostgreSQL: Check if row exists or another row has a specific value
body: <p>I have the following tables:
  <img src="https://i.stack.imgur.com/V3vdt.png" alt="enter image description here"></p>
  
  <p>When a new ComputerComponents is created, the database should check and only allow the insertion IF one is true:</p>
  
  <ul>
  <li>ComputerComponent has a component which is a ComponentType with name = 'GPU'</li>
  </ul>
  
  <p>OR</p>
  
  <ul>
  <li>ComputerComponent has a component which is a ComponentType with name = 'CPU' AND the CPU has a Attribute with name = 'Onboard-GPU' and the ComponentAttribute value = TRUE</li>
  </ul>
  
  <p>How do i do this?</p>