Question

In: Computer Science

Use the SQL Developer to create the four tables EMP, DEPT, PROJ, EMP_PROJ with the appropriate...

  1. Use the SQL Developer to create the four tables EMP, DEPT, PROJ, EMP_PROJ with the appropriate constraints except FOREIGN KEY constraints. For filename, use CREATE.sql accordingly.
  2. Import data from the csv files to EMP, DEPT, and PROJ tables.
  3. Check that all data for EMP, DEPT, and PROJ tables has been imported.

__________________________

employees.csv

empNo,fname,lname,address,sex,salary,position,deptNo

1000,Steven,King,"731 Fondren, Houston, TX",M,30000,Programmer,60

1007,Diana,Lorentz,"638 Voss, Bellaire, TX",F,24000,Clerk,20

2002,Pat,Fay,"3321 Castle, Spring, TX",F,15000,Sales Representative,80

1760,Jonathan,Taylor,"561 Rice, Houston, TX",M,60000,Manager,20

1740,Ellen,Abel,"890 Stone, Houston, TX",F,65000,Manager,60

2060,William,Gietz,"450 Berry, Bellaire, TX",M,65000,Manager,80

2000,Jennifer,Whalen,"980 Fire Oak, Humble, TX",F,28000,Clerk,60

1444,Peter,Vargas,"975 Dallas, Houston, TX",M,20000,Sales Representative,80

_________________________________

Departments.csv

deptNumber,deptName,Mgr

20,Marketing,1760

60,IT,1740

80,Sales,2060

_________________________

Projects.csv

projNumber,projName,deptNum

10,Product X,20

20,Product Y,20

30,Computerization,60

40,Product Z,80

50,Mobile Apps,60

Solutions

Expert Solution

MySQL code for create tables.



create Table DEPT(
        deptNumber INT NOT NULL,
        deptName VARCHAR(200),
        Mgr INT,
        PRIMARY KEY(deptNumber)
);

create Table PROJ(
        projNumber INT NOT NULL,
        prohName VARCHAR(200),
        deptNum INT,
        PRIMARY KEY(projNumber),
        FOREIGN KEY(deptNum) REFERENCES DEPT(deptNumber)
);


create Table EMP(
        empNO INT NOT NULL,
        fname VARCHAR(200),
        lname VARCHAR(200),
        address VARCHAR(200),
        sex VARCHAR(1),
        salary REAL,
        position VARCHAR(200),
        depNo INT,
        PRIMARY KEY(empNo),
        FOREIGN KEY(depNo) REFERENCES DEPT(deptNumber)
);

create Table EMP_PROJ(
        projNumber INT NOT NULL,
        empNO INT NOT NULL,
        PRIMARY KEY(projNumber, empNO),
        FOREIGN KEY(projNumber) REFERENCES PROJ(projNumber),
        FOREIGN KEY(empNO) REFERENCES EMP(empNO)
);
        

Load CSV file into databse.


LOAD DATA INFILE '/home/daenerys/Desktop/Departments.csv'
INTO TABLE DEPT
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS


LOAD DATA INFILE '/home/daenerys/Desktop/Projects.csv'
INTO TABLE PROJ
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS


LOAD DATA INFILE '/home/daenerys/Desktop/employees.csv'
INTO TABLE EMP
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS

Select data from database


SELECT * FROM EMP;

SELECT * FROM DEPT;

SELECT * FROM PROJ;

Related Solutions

Develop the SQL scripts that will create the tables and enforce all the appropriate constraints •...
Develop the SQL scripts that will create the tables and enforce all the appropriate constraints • Develop sample SQL scripts that will insert the data to the database (one row in each table) • Convert at least 2 entities to MongoDB Collections. Write the scripts that will Create the collection(s)
Developer User Account Create a user account using T-SQL for developers named DEVELOPER with the password...
Developer User Account Create a user account using T-SQL for developers named DEVELOPER with the password TESTACCOUNT that grants the user the ability to: Select and modify any table. Connect to and have access to all resources. In SSMS
Create a table in SQL with foreign key reference: 1.Create the three tables without any columns...
Create a table in SQL with foreign key reference: 1.Create the three tables without any columns 2.Alter the tables to add the columns 3.Alter the tables to create the primary and foreign keys
Using SQL Developer Question 1 Create a block to retrieve and display pledge and payment information...
Using SQL Developer Question 1 Create a block to retrieve and display pledge and payment information for a specific donor. For each pledge payment from the donor, display the pledge ID, pledge amount, number of monthly payments, payment date, and payment amount. The list should be sorted by pledge ID and then by payment date. For the first payment made for each pledge, display “first payment” on that output row. Question 2 Redo question 1, but use a different cursor...
Write the SQL DDL to create the following 5 tables for an App store: Publisher, Category,...
Write the SQL DDL to create the following 5 tables for an App store: Publisher, Category, App, AppVersion, AppVersionReview: A Publisher table where each publisher is identified by an integer id and has a name (up to 40 characters). (1 mark) A Category table where each category has an id (integer), a name (up to 50 characters), and a parentId to identify its parent category. The parentId should be a foreign key to the Category table. (1.5 marks) An App...
SQL code Create entities (tables) to represent the following ternary relationship. Note that we are not...
SQL code Create entities (tables) to represent the following ternary relationship. Note that we are not storing all the required information in these entities to simplify it. The underlined attributes are the primary keys. Don’t forget to set the constraints for primary and foreign keys: •A student entity ( bannerId, first name, last name, date of birth) •A course entity ( crnNumber, course name, # of credits) •An examination entity ( examId, exam_type, exam_date). (exam types can be “Midterm”, “Final”,...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based on your entities defining The attributes within each table The primary and foreign keys within each table *****Show your database tables, tables attributes, primary and foreign keys***** Do not forget to check the lesson slides and videos that show you how to convert an ER/EER into a database schema, and how to create a database and tables using MS SQL Server.
Consider the following SQL DDL statements: CREATE TABLE DEPT ( did INTEGER, dname VARCHAR(20), PRIMARY KEY(did));...
Consider the following SQL DDL statements: CREATE TABLE DEPT ( did INTEGER, dname VARCHAR(20), PRIMARY KEY(did)); CREATE TABLE EMP( eid INTEGER, name VARCHAR(20), did INTEGER, PRIMARY KEY(eid), FOREIGN KEY(did) REFERENCES DEPT); In the database created by above statements, which of the following operations may cause violation of referential integrity constraints? Question 1 options: UPDATE on DEPT INSERT into DEPT DELETE on EMP Both DELETE on EMP and INSERT into DEPT
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT