Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, I am currently in an Intro to Database class and I am learning the basics of

ID: 3703145 • Letter: H

Question

Hi,

I am currently in an Intro to Database class and I am learning the basics of SQL at the moment. I am currently working on an assignment and I am getting an error for when I am entering values into the data tables. The error is ORA-02291: integrity constraint (SQL_DEIJPYXRBUPSAXYFLBNFLXZED.SYS_C001408692) violated - parent key not found ORA-06512: at "SYS.DBMS_SQL", line 1721 . I am stuck and not sure what to do right now; I have posted the assignment and the code I have so far. I appreciate the help!

Thanks!

Assignment

Code:

CREATE Table store
( storeid VARCHAR (3) NOT NULL,
storezip CHAR (5) NOT NULL,
PRIMARY KEY (storeid));

CREATE Table employee
( employeeid VARCHAR(5) NOT NULL,
employeefname VARCHAR(25) NOT NULL,
employeelname VARCHAR(25) NOT NULL,
storeid VARCHAR(3) NOT NULL,
PRIMARY KEY (employeeid),
FOREIGN KEY (storeid) REFERENCES store(storeid) );

INSERT INTO employee VALUES ('E1234' , 'George', 'Loocas','S1');
INSERT INTO employee VALUES ('E1235', 'Steven', 'Speelberg', 'S2');

Assume that you will need to create one more table in your database for keeping track of employees who work in the store. Each store will have many employees and each employee works in a particular store. StorelQ StoreZip EmployeeFName STORE EMPLOYEE has EmployeeLName Create the Employee table assuming EmploveelD can be captured using five characters, employee first name and last name can be captured using 25 characters. Make sure to include StoreID as the the foreign key field in the Employee table pointing to Storell field in the Store table. 1. SQL Enter two records for Employees with the following data: Employee ID, Employee First Name, Employee Last Name, Storen E1234 George, Lgocas, S1 E1235, Steven, Speelberg, S2

Explanation / Answer

Answer)

I understand that you're getting an error for entering values into the data tables in Employee table. There is a violation for the integrity constraint as there is no Store Id present in the Store table for the foreign key storeid in the employee table. So we have to first insert corresponding values in the Store table and then insert values in the Employee table. The code for it is as below:

CREATE Table store

( storeid VARCHAR (3) NOT NULL,

storezip CHAR (5) NOT NULL,

PRIMARY KEY (storeid));

CREATE Table employee

( employeeid VARCHAR(5) NOT NULL,

employeefname VARCHAR(25) NOT NULL,

employeelname VARCHAR(25) NOT NULL,

storeid VARCHAR(3) NOT NULL,

PRIMARY KEY (employeeid),

FOREIGN KEY (storeid) REFERENCES store(storeid) );

insert into store values('S1','78867');

insert into store values('S2','66553');

INSERT INTO employee VALUES ('E1234' , 'George', 'Loocas','S1');

INSERT INTO employee VALUES ('E1235', 'Steven', 'Speelberg', 'S2');

On executing the above script values will be successfully inserted in the Employee Table.

This you can check by the query:

select * from employee;

Output:

employeeid employeefname employeelname storeid

E1234 George Loocas S1

E1235 Steven Speelberg S2

The above is the desired output.

/*Hit Like if you like my answer*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote