PostgreSQL: Check if row exists or another row has a specific value
I have the following tables:
When a new ComputerComponents is created, the database should check and only allow the insertion IF one is true:
ComputerComponent has a component which is a ComponentType with name = 'GPU'
OR
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