Question

In: Computer Science

Use MySQL server. First step: create and use database called EDU. Syntax: CREATE SCHEMA edu; USE...

Use MySQL server.
First step: create and use database called EDU.
Syntax:
CREATE SCHEMA edu;
USE edu;

Create a script which will create the tables listed below:
STUDENT(STUDENT_ID, STUDENT_NAME, MAJOR_ID, DOB, PHONE_NUMBER)
MAJOR(MAJOR_ID, MAJOR_NAME)
ENROLLMENT(STUDENT_ID, COURSE_ID, GRADE)
COURSE(COURSE_ID, COURSE_NAME)
RESPONSIBILITY(FACULTY_ID, COURSE_ID)
TEACHER(FACULTY_ID, DEPT_ID, TEACHER_NAME)
DEPARTMENT(DEPT_ID, DEPARTMENT_NAME)

Start the script with a series of DROP statements so that as you correct mistakes you will start fresh each time. To avoid referential integrity errors, the table drops should be in the opposite order of the create table statements.

Put script name and your name in the script heading –see example:
Example of a script:
/*script1.sql
Student Name: ------*/
USE sh;
DROP TABLE IF EXISTS part;
DROP TABLE IF EXISTS salesrep;
CREATE TABLE part
(Partno    CHAR(4) PRIMARY KEY,
Partdesc VARCHAR(20),
Onhand    INTEGER,
Partclass CHAR(2) check (Partclass IN ('AP','HW','KI','SP')),
Unitprice DECIMAL(6,2)
);
CREATE TABLE salesrep
(Srepno     CHAR(3),
Srepname   VARCHAR(25),
Srepstreet VARCHAR(30),
Srepcity   VARCHAR(15) NOT NULL,
Srepprov   VARCHAR(3) NOT NULL,
Sreppcode VARCHAR(6) NOT NULL,
Totcomm    DECIMAL(8,2),
Commrate   DECIMAL(3,2),
CONSTRAINT pkslsrep PRIMARY KEY (Srepno)
);

Solutions

Expert Solution

/*myscript.sql
Student Name:_______________*/

/* For creating the database use any of these command
CREATE SCHEMA edu; (or) CREATE DATABASE edu;
*/

USE edu;

DROP TABLE IF EXISTS RESPONSIBILITY;
DROP TABLE IF EXISTS TEACHER;
DROP TABLE IF EXISTS DEPARTMENT;
DROP TABLE IF EXISTS ENROLLMENTS;
DROP TABLE IF EXISTS COURSE;
DROP TABLE IF EXISTS STUDENT;
DROP TABLE IF EXISTS MAJOR;

CREATE TABLE MAJOR
(
MAJORID VARCHAR(10),
MAJORNAME VARCHAR(25),
PRIMARY KEY (MAJORID)
);

CREATE TABLE STUDENT
(
STUDENTID VARCHAR(10),
STUDENTNAME VARCAHR(25),
MAJORID vARCHAR(10),
DOB DATE,
PHONENUMBER INTEGER,
PRIMARY KEY (STUDENTID),
FOREIGN KEY (MAJORID) REFERENCES MAJOR(MAJORID)
);


CREATE TABLE COURSE
(
COURSEID VARCHAR(10),
COURSENAME VARCHAR(25),
PRIMARY KEY (COURSEID)
);

CREATE TABLE ENROLLMENTS
(
STUDENTID VARCHAR(10),
COURSEID VARCHAR(10),
GRADE CHAR(1),
FOREIGN KEY (STUDENTID) REFERENCES STUDENT(STUDENTID),
FOREIGN KEY (COURSEID) REFERENCES COURSE(COURSEID)
);

CREATE DEPARTMENT
(
DEPTID VARCHAR(10),
DEPARTMENTNAME VARCHAR(25),
PRIMARY KEY(DEPTID)
);

CREATE TEACHER
(
FACULTYID VARCHAR(10),
DEPTID VARCHAR(10),
TEACHERNAME VARCHAR(25),
PRIMARY KEY (FACULTYID),
FOREIGN KEY (DEPTID) REFERENCES DEPARTMENT(DEPTID)
);

CREATE RESPONSIBILITY
(
FACULTYID VARCHAR(10),
COURSEID VARCHAR(10),
FOREIGN KEY (FACULTYID) REFERENCES TEACHER(FACULTYID),
FOREIGN KEY (COURSEID) REFERENCES COURSE(COURSEID)
);

---------------------------------------------------------------------------------------------------------------------------------------------------------
Note:Here i am taking all id's as a combination of the letters and alphabets so i took that data type as varchar.


Related Solutions

Part 2: Use MySQL Workbench to add a table to your database on the class server...
Part 2: Use MySQL Workbench to add a table to your database on the class server and name the table “Person”. Include these fields in the Person table: Field Name Description Data Type Sample Value LoginID User’s login name varchar(10) Bob FirstName User’s first name varchar(50) Bob LastName User’s last name varchar(50) Barker picUrl Filename of the user’s picture varchar(50) bob.gif Bio User’s biography varchar(255) Bob is the best! LoginID should be the Primary Key of the table. Add at...
This refer to the “om” database (or Schema) that you will find in your MySQL Workbench...
This refer to the “om” database (or Schema) that you will find in your MySQL Workbench program if you have run the sample database install script. Please save all of your answers in one script (.sql) or type all your answers into Notepad++ and submit them as a single .sql file. Please test your SQL statements in Workbench 1.       Using an INNER JOIN, select the order_id, order_date, shipped_date, fname, and customer_phone from the orders and customers tables. The fname is a...
We use the WMCRM database and here is the summary of the database schema (where schema...
We use the WMCRM database and here is the summary of the database schema (where schema is used in its meaning of a summary of the database structure): VEHICLE (InventoryID, Model, VIN) SALESPERSON (NickName, LastName, FirstName, HireDate, WageRate, CommissionRate, OfficePhone, EmailAddress, InventoryID) CUSTOMER (CustomerID, LastName, FirstName, Address, City, State, ZIP, EmailAddress, NickName) PHONE_NUMBER (CustomerID, PhoneNumber, PhoneType) CONTACT(ContactID, CustomerID,ContactDate,ContactType,Remarks) Where InventoryID in SALESPERSON must exist in InventoryID in VEHICLE NickName in CUSTOMER must exist in NickName in SALESPERSON CustomerID in PHONE_NUMBER...
"How can I connect my hadoop database or mysql database server to my d3 visual?"
"How can I connect my hadoop database or mysql database server to my d3 visual?"
Using the sample.sql script, create the sample database in MySQL. Submit the MySQL interactive screen that...
Using the sample.sql script, create the sample database in MySQL. Submit the MySQL interactive screen that results. create database sample; use sample; create table customer (custno int auto_increment primary key, firstname varchar(20), middle varchar(20), lastname varchar(20), address varchar(60), telnum1 varchar(10), telnum2 varchar(10), telnum3 varchar(10), pin varchar(6), email varchar(30)); create table accttype (id int primary key, type varchar(10)); insert into accttype (id, type) values (1,'check'); insert into accttype (id, type) values (2,'save'); insert into accttype (id, type) values (3,'cd'); insert into...
using the lyrics database schema in mysql provided below. 1.)List the artist name of the artists...
using the lyrics database schema in mysql provided below. 1.)List the artist name of the artists who do not have a webaddress and their leadsource is “Directmail”? 2.)List the names of members in the artist called 'Today'. 3.)Report the total runtime in minutes FOR EACH album in the Titles table. 4.)List the firstname, lastname of members who are represented by the salesperson “Lisa Williams” 5.)List EACH salesperson’s firstname along with the number of Members that EACH SalesPerson represents. below is...
In MySQL, create a new schema titled <yourlastname>module3. Using the below file, create the tables in...
In MySQL, create a new schema titled <yourlastname>module3. Using the below file, create the tables in your new schema and populate with the supplied data. Tables do not have keys. Do not define them at this time. There are errors in the data population (INSERT) statements. It is your job to find the errors and correct them. This is important. You will need correct data for future exercises in this module. In the submission area, choose Write Submission and identify...
• Relational Schema Create a relational database schema consisting of the four relation schemas representing various...
• Relational Schema Create a relational database schema consisting of the four relation schemas representing various entities recorded by a furniture company.   Write CREATE TABLE statements for the following four relation schemas. Define all necessary attributes, domains, and primary and foreign keys. Customer(CustomerID, Name, Address) FullOrder(OrderID, OrderDate, CustomerID) Request(OrderID, ProductID, Quantity) Product(ProductID, Description, Finish, Price) You should assume the following: Each CustomerID is a number with at most three digits, each OrderID is a number with at most five digits,...
Create the actual database using SQL syntax. This is completed using a Database Application (i.e Microsoft...
Create the actual database using SQL syntax. This is completed using a Database Application (i.e Microsoft Access, Oracle, or MySQL) as indicated by your professor. After creating the database – populate it with some data (could be made up). SQL syntax and the DB application will be discussed and taught in class. This is the final deliverable of the group project. Assignment is due by the due date as indicated by your professor. *Make sure to submit the completed database...
Using MYSQL in terminal, create the tables for your above designed relational schema and populate your...
Using MYSQL in terminal, create the tables for your above designed relational schema and populate your tables with appropriate data. All except time slot and the relationship it participates in. Use the names for the tables and attributes from the ER schema. Use ON DELETE CASCADE for foreign keys. Each basic table (corresponding to an entity in the ER schema developed for Part 1) should have 5-10 rows. Campus can have just 2. Building should have at least 6. At...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT