Question

Suppose you are given the table: EMPLOYEE_DEPARTMENT (EmployeeNumber, EmployeeLastName, EmployeeFirstName, Email, DepartmentName, BudgetCode) You want to...

Suppose you are given the table:

EMPLOYEE_DEPARTMENT (EmployeeNumber, EmployeeLastName, EmployeeFirstName, Email, DepartmentName, BudgetCode)

You want to create an updated database and normalize the table

into the two tables:

DEPARTMENT (DepartmentName, BudgetCode)

EMPLOYEE (EmployeeNumber, EmployeeLastName, EmployeeFirstName, Email, DepartmentName)

Show SQL statements for creating DEPARTMENT and EMPLOYEE.

Show SQL filling the EMPLOYEE and DEPARTMENT tables with data from EMPLOYEE_DEPARTMENT.

Homework Answers

Answer #1

creating DEPARTMENT and EMPLOYEE

/*Create DEPARTMENT with DepartmentName as primary key and use it as foreign key in EMPLOYEE to link the two tables*/

CREATE TABLE DEPARTMENT (

DepartmentName varchar(255),

BudgetCode varchar(255),

PRIMARY KEY (DepartmentName)

);

CREATE TABLE EMPLOYEE (

EmployeeNumber int,

EmployeeLastName varchar(255),

EmployeeFirstName varchar(255),

Email varchar(255),

DepartmentName varchar(255),

FOREIGN KEY (DepartmentName) REFERENCES DEPARTMENT(DepartmentName)

);

filling the EMPLOYEE and DEPARTMENT tables -

INSERT INTO DEPARTMENT (DepartmentName, BudgetCode)
SELECT DepartmentName, BudgetCode FROM EMPLOYEE_DEPARTMENT ;

INSERT INTO EMPLOYEE (EmployeeNumber, EmployeeLastName, EmployeeFirstName, Email, DepartmentName)
SELECT EmployeeNumber, EmployeeLastName, EmployeeFirstName, Email, DepartmentName FROM EMPLOYEE_DEPARTMENT ;

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Purpose: The purpose of this assignment is to provide an opportunity for you to write SQL...
Purpose: The purpose of this assignment is to provide an opportunity for you to write SQL statements to create tables and insert data into tables. Skills: Learn and practice the techniques of writing SQL statements using SQL Server Management Studio(SSMS).   Knowledge: By doing this assignment you will learn to use SSMS and write SQL statements to create new tables and insert data into the tables. Tasks: Use the following figure for the tasks below: [15 points] Write SQL statements to...
If you had to create a new table in your database called EMPLOYEE and load data...
If you had to create a new table in your database called EMPLOYEE and load data into it using SQL commands below. CREATE TABLE EMPLOYEE (               EMP_ID INT PRIMARY KEY,               EMP_FNAME VARCHAR(200) NOT NULL,               EMP_LNAME VARCHAR(200) NOT NULL,               EMP_CITY VARCHAR(500) NULL ,               EMP_STATE VARCHAR(20) NULL ) INSERT INTO EMPLOYEE VALUE (1, ‘Kevin’, ‘Lailnay’, NULL, ‘PA’) INSERT INTO EMPLOYEE VALUE (2, ‘Sarita, ‘Kawn, ‘Princeton’,’NJ’) INSERT INTO EMPLOYEE VALUE (2, ‘Gloria, ‘Pitts, ‘Allentown, ‘PA’) INSERT INTO EMPLOYEE...
EMPLOYEE Field Name EMP_ID EMP_LNAME EMP_MI EMP_FNAME EMP_SEX EMP_AGE EMP_SALARY EMP_HIREDATE DEPT_CODE Table: DEPARTMENT DEPT_CODE BIOL...
EMPLOYEE Field Name EMP_ID EMP_LNAME EMP_MI EMP_FNAME EMP_SEX EMP_AGE EMP_SALARY EMP_HIREDATE DEPT_CODE Table: DEPARTMENT DEPT_CODE BIOL CPTR HIST MATH RELB Data Type Text Text Text Text Text Number Currency Date/Time Text DEPT_TITLE Biology Computer Science History Mathematics Religion    Field Name DEPT_CODE DEPT_TITLE Data Type Text Text INSTRUCTIONS Use SQL commands to create the tables and enter the data shown above using MS Access. Write the following SQL statement given below: 1. 2. 3. 4. 5. 6. 7. 8. 9....
Assignment 2 Instructions You need to access to the database and write SQL queries on the...
Assignment 2 Instructions You need to access to the database and write SQL queries on the following site: https://www.w3schools.com/sql/trysql.asp?filename=trysql_op_in 1. Use INNER JOIN to create a report. In this report, list each customer’s CustomerID, CustomerName, and their each OrderID and each order’s OrderDate, if the customer has ever placed an order. You should use the Customers table and the Orders table in the database to complete this query.   2. Use INNER JOIN to create a report. In this report, list...
Question 2 (5 Marks) What can you say about the relationships between Courses and Subject, and...
Question 2 What can you say about the relationships between Courses and Subject, and Courses and Students? Will there be any problems in creating a Relational Database from your ER diagram? If there is, then describe how you will address this and re-draw the ER diagram. Question 3 Create the DDL statements to create the tables described in your modifies ER diagram in Question 2. Question 4 In your Database you created in Question 3, assume there is a student...
Lab 5 Queries with Multiple Tables In this lab, we do queries more than one table....
Lab 5 Queries with Multiple Tables In this lab, we do queries more than one table. SQL provides two different techniques for querying data from multiple tables: • The SQL subquery • The SQL join As you will learn, although both work with multiple tables, they are used for slightly different purposes. We used WMCRM database which is what we created in Lab 4. Here is the summary of the database schema (where schema is used in its meaning of...
Save your select statements as a script. Place the semicolon at the end of each SQL...
Save your select statements as a script. Place the semicolon at the end of each SQL statement. Please number your select statements from 1 to 8 in your script and comment out each number. Include your name and student number as a comment at the top of your script. The name of the script has to be Assignment1_JohnSmith. Instead of JohnSmith use your First Name and Last Name. Upload your script trough Blackboard. Use SQL Developer to create the My...
Create 2 stored procedures: sp_AddNewUser and sp_AddNewRole. Use the ManyToMany script as your base table structures....
Create 2 stored procedures: sp_AddNewUser and sp_AddNewRole. Use the ManyToMany script as your base table structures. The stored procedure should accept the parameters needed to input the data for each table. NOTE: You do not need to input the UserID or RoleID. These are surrogate keys and the system automatically inserts them when you insert a row in the tables.   On execution, the stored procedure should check the database to see if the user exists, if so, return a message...
You want to design a database for an automobile dealership with three locations. A vehicle's data...
You want to design a database for an automobile dealership with three locations. A vehicle's data fields include stock number (a common name for SKU (Stock Keeping Unit)), vehicle identification number (VIN), make, model, year, color and invoice cost. Identify the possible candidate keys, the likely primary key, probably foreign keys, and potential secondary keys for the Vehicle table. Identify other tables the Vehicle table might need to form a relationship (or link with).
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects....
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects. The charges are based on the hours each employee works on each project. The structure and contents of the Ch08_ConstructCo database are shown in Figure P8.1. Use this database to answer the following problems. Database Schema The schema for the Ch08_ConstructCo database is shown below and should be used to answer the next several problems. Click this image to view it in its own...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT