1. A database called assignment1 is created and tables Department and Employee are created within it to store department and employee data.
2. Data is inserted into the Department table for 5 departments and into the Employee table for 6 employees which includes employee name, department number, and salary.
3. An attempt to insert a new employee with an invalid department number results in a foreign key constraint error since the department number does not exist in the Department table.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
53 views5 pages
Assignment 1
1. A database called assignment1 is created and tables Department and Employee are created within it to store department and employee data.
2. Data is inserted into the Department table for 5 departments and into the Employee table for 6 employees which includes employee name, department number, and salary.
3. An attempt to insert a new employee with an invalid department number results in a foreign key constraint error since the department number does not exist in the Department table.
ENAME VARCHAR(10) NOT NULL, DNO INT(2), FOREIGN KEY REFERENCES Department(DNO), SALARY INT(6)); 3. Insert Datas in tables → INSERT INTO Department(DNO,DNAME) VALUES (10,"Admin"); INSERT INTO Department(DNO,DNAME) VALUES (20,"Accounts"); INSERT INTO Department(DNO,DNAME) VALUES (30,"Sales"); INSERT INTO Department(DNO,DNAME) VALUES (40,"Marketing"); INSERT INTO Department(DNO,DNAME) VALUES (50,"Purchasing"); INSERT INTO Employee(ENO,ENAME,DNO,SALARY) VALUES (1,"Amal",10,30000); INSERT INTO Employee(ENO,ENAME,DNO,SALARY) VALUES (2,"Shyamal",30,50000); INSERT INTO Employee(ENO,ENAME,DNO,SALARY) VALUES (3,"kamal",40,10000); INSERT INTO Employee(ENO,ENAME,DNO,SALARY) VALUES (4,"nirmal",50,60000); INSERT INTO Employee(ENO,ENAME,DNO,SALARY) VALUES (5,"Bimal",20,40000); INSERT INTO Employee(ENO,ENAME,DNO,SALARY) VALUES (6,"Parimal",20,20000); 4. Display all data from the Department table. → SELECT * FROM Department; 5. Display all data from the Employee table. → SELECT * FROM Employee;
6. Insert [1,akash,60,70000] value in Employee table(copy error
message). → UPDATE Employee SET ENO=1, ENAME="akash",DNO=60,SALARY=70000;
ERROR 1452 (23000): Cannot add or update a child row: a