adding CHECK to impose constraints on more than one table

后端 未结 4 1682
我在风中等你
我在风中等你 2021-01-29 02:57

I want to modify the following DDL to add CHECK constraints so that the manager of a store works at the same store and a store supplies all the products if its type is \'local\'

4条回答
  •  感情败类
    2021-01-29 03:52

    A CHECK constraint is limited to a single row in a single table.

    If you really want to implement that kind of check I guess you would have to use triggers.

    Note that you have modeled a many-to-many relationship for works-at and manages. If it were a many-to-one it would have been doable because it would look like Employee(number, name, works_at_store_code, manages_store_code). And the constraint would simply be CHECK (manages_store_code is null or manages_store_code = works_at_store_code).

提交回复
热议问题