Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1954

Possible constraint creation (4 replies)

$
0
0
Is there a way to add a constraint between tables that would prevent a record from being deleted from table1 if it exists in table2, but table2 does not have to have an entry from table1.

Example: Table1 is sub_department information with an id field. Table2 is a department configuration table. Table2 has dept_id and sub_dept_id. Some configurations are only for the combination dept_id and sub_dept_id so a matching record must exist in the department table and sub-department table for corresponding id's. Since it is possible only the department has configuration information then sub_dept_id would default to zero. (not in the sub-department table). Because of this I can not add a normal constraint that would stop a sub_department from being removed if it is used in the configuration table.

Thoughts? Thanks!

Viewing all articles
Browse latest Browse all 1954

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>