I have these three tables,
- menu
- item
- category
And the relationship among all these tables are,
- A menu can have multiple items and categories. So menu has a one-to-many relationship with item and category.
- Item and category have a many-to-many relationship
- Furthermore, the constraint I am thinking is that item and category can only be connected if they are both under the same menu.
Currently I am thinking to enforce the first two contraint (one-to-many and many-to-many) in the database and handle the 3rd constraint in application side.
Is there a better way in postgres or any other db to define this type of conditional constraint? If yes, is there a industry term for it?
