Answered step by step
Verified Expert Solution
Question
1 Approved Answer
[Q.2] Answer the following questions. [18 points] (a) Write two SQL statements to create a database (or schema) simpleCo if the database does not exist,
[Q.2] Answer the following questions. [18 points] (a) Write two SQL statements to create a database (or schema) simpleCo if the database does not exist, and use simpleCo. (b) Drop tables employee and department from the simpleCo if the tables exist in the simpleCo schema. (c) Write a SQL statement to create a table department as described below. Type Key Default deptid tinyint(4) varchar(40) YES (d) Write a SQL atement to alter Dname column type from varchar(40) to varchar(30), not NULL, and default value to empty string (i.e, ') as shown below. Field Null NULL NO PRI NULL Dname Null Key Extra Default NULL Field deptid dname Type tinyint(4) varchar(30) PRI NO NO 1 (e) Write a SQL statement to populate department table as shown below. deptid Dname Research Human Resource Sales (f) Write a SQL statement to create employee table as shown below. Note dno in employee is foreign key referencing deptId in the department table. Your SQL statement to create employee table should include a foreign key constraint named fk_etod for adding the foreign key constraint. 2 3 Null Extra Key PRI Default NULL NO NULL Field employeeld Fname Lname salary dno Type char(9) varchar(20) varchar(20) decimal(10,2) tinyint(4) NO NO NULL NULL NO YES MUL NULL
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started