Sunday 15 May 2011

sql - adding CHECK to impose constraints on more than one table -


I want to modify the following DDL to add check barriers so that one store manager works on the same store and store Can not help

  create employee employee (employee_number CHAR (5), no one can name the name VARCHAR (30), virtual key (employee_number), foreign key (store_code) reference Shop) Create Table Collection (store_code CHAR (5) No, Type VARCHAR Type (15), tax MARC_CODE CHAR (5), primary key (store_code) foreign key (employee_number) referrer employee) Table forming product (ProductCorad CRAR) not faucet, description VARCHAR (150), cost DEC (10,2), primary key (product code)) Make Tables Stocks (StoreCode CRAR (5) No NULL, Product_code CHAR (5) Faucet, primary key (product_code, store_code), foreign key (product_key) reference product, foreign key (store_code) reference forum)    

The lack of an investigation is limited to a line on a table.

If you really want to implement such investigations then I think that you have to use triggers.

Note that you have established many relationships for work-related and management. If it were multiple-to-one, then it would be possible because it would look like the employee (number, name, work_t__store_code, management_store_code). And the constraint will be checked only (manages_store_code is zero or management_store_code = task_t__store_code).

No comments:

Post a Comment