Create a relation that represents the dependence between objects. The table shou
ID: 3879111 • Letter: C
Question
Create a relation that represents the dependence between objects. The table should have two attributes called object and dependent, where object is the primary key of the relation and dependent is a foreign key that references object. Then insert three tuples into this table:
1. o1 is dependent on o2
2. o2 is dependent on o3
3. o3 is dependent on o1
Note that this problem is similar to chicken-egg problem but only involves one relation. What you need to submit is proper DDL and DML statements in sequence that can accomplish this with Oracle-VM.
Explanation / Answer
Hi,
Below are the DDL and DML statement. DDL create table will execute successfully but DML will not execute.
The reason is because of below reasons-
1. o1 is dependent on o2 - We are trying to insert the dependent o2 here which does not exist in the object column.
As a result, we get the integrity constraint violation error-
ORA-02291: integrity constraint (SQL_QCIWFJAKILUMKJVCAOCLUGLQZ.SYS_C006921033) violated - parent key not found ORA-06512: at "SYS.DBMS_SQL", line 1721
2. o2 is dependent on o3 - We are trying to insert the dependent o3 here which does not exist in the object column.
As a result, we get the integrity constraint violation error
3. o3 is dependent on o1 - We are trying to insert the dependent o1 here which does not exist in the object column.
As a result, we get the integrity constraint violation error
DDL Statements-
CREATE TABLE TEST(OBJECT VARCHAR(20) PRIMARY KEY, DEPENDENT VARCHAR(20) REFERENCES TEST(OBJECT));
INSERT INTO TEST VALUES('o1','o2');
INSERT INTO TEST VALUES('o2','o3');
INSERT INTO TEST VALUES('o3','o1');
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.