Declare and exercise a native optional InnoDB reference
In an authorized isolated lab only, create fixed database cxdbmslabfkeasy and persistent InnoDB departments/ employees with the definitions in the reference contract: departmentid parent primary key; employeeid child primary key; nullable employee departmentid referencing the parent. Before each copy, clear only these disposable child rows then parent rows, without disabling checks. Copy supplied inputs and return employeeid,department_id. Positive fixtures contain only matching nonmissing references or NULL.
MySQL dialect.
sqlCREATE TABLE department_input (department_id INT PRIMARY KEY); CREATE TABLE employee_input (employee_id INT PRIMARY KEY,department_id INT NULL); INSERT INTO department_input VALUES (10); INSERT INTO employee_input VALUES (1,10),(2,NULL);
Required ordering: Ascending employee_id.
Edge cases:
- NULL reference is permitted.
- A nonmissing unknown parent is rejected.
INSERT INTO department_input VALUES (10); INSERT INTO employee_input VALUES (1,10),(2,NULL);
employee_id department_id 1 10 2 NULL
Explanation: The actual persistent InnoDB child references the declared parent identity; positive and negative cases exercise optional matching without a query-only simulation.
- Persistent InnoDB native constraint in fixed disposable cx_dbms_lab_fk_easy only.
- Administrative lab capability required; no application tables are targets.
Hint 1
Declare the parent before its child.
Hint 2
Do not confuse a nullable reference with required participation.
The actual persistent InnoDB child references the declared parent identity; positive and negative cases exercise optional matching without a query-only simulation.
The actual persistent InnoDB child references the declared parent identity; positive and negative cases exercise optional matching without a query-only simulation.
Related Problems
- Cascade only the complete selected parent identityMedium · sqlSolve Problem
- Select one student occurrence by identityEasy · sqlSolve Problem
- Create a disposable database with explicit text defaultsEasy · sqlSolve Problem