Example table:
Ticket
- id
- tenant_id
- foo
TicketItem
- id
- tenant_id
- ticket_id
- bar
Assuming that id and tenant_id on each table make up composite primary keys, and that ticket_id is a foreign key to Ticket will this setup protect me from a circumstance where a TicketItem has tenant_id=1 and ticket_id=5 where the Ticket with id=5 has tenant_id=2? In simpler words, would the database allow me to link rows from 2 tables - each with different tenant_id - together, ruining my data, or does it protect me from this?
Also, does the above example seem like a "good" use of a composite primary key?