Question

The lab for this week addresses taking a logical database design (data model) and transforming it into a physical model (tabl
o Create all FK constraints as indicated in the ERD. Create all of the tables and all of the constraints before populating an
Refer to the following ERD In constructing your solution. Instructor Student Student ID Zipcode PK Instructor_ID PK Zip City
Step 2. The data for each table is contained in text files, named for the table whose data it contains. Modify the format of
0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

Step-1:

DROP TABLE IF EXISTS 'Enrollment';

DROP TABLE IF EXISTS 'Section';

DROP TABLE IF EXISTS 'Student';

DROP TABLE IF EXISTS 'Instructor';

DROP TABLE IF EXISTS 'ZipCode';

DROP TABLE IF EXISTS 'Course';

Step-2:

CREATE TABLE ZipCode(

    Zip INT NOT NULL PRIMARY KEY,

    City VARCHAR(50),

    State VARCHAR(10)

);

CREATE TABLE Student(

    Student_ID INT NOT NULL PRIMARY KEY,

    Saluation VARCHAR(5),

    First_Name VARCHAR(30),

    Last_Name VARCHAR(30),

    Street_Address VARCHAR(50),

    Phone VARCHAR(15),

    Employer VARCHAR(20),

    Registration_Date DATE,

    Zip INT,

    FOREIGN KEY(Zip) REFERENCES Zipcode(Zip)

);

CREATE TABLE Instructor(

    Instructor_ID INT NOT NULL PRIMARY KEY,

    Saluation VARCHAR(5),

    First_Name VARCHAR(50),

    Last_Name VARCHAR(50),

    Street_Address VARCHAR(50),

    Zip INT,

    FOREIGN KEY(Zip) REFERENCES Zipcode(Zip)

);

CREATE TABLE Course(

    Course_ID CHAR(6) NOT NULL PRIMARY KEY,

    Description VARCHAR(100),

    Cost FLOAT(6,2),

    Prerequisite CHAR(6)

);

CREATE TABLE Section(

    Section_ID CHAR(6) NOT NULL PRIMARY KEY,

    Course_Section_Num INT,

    Start_Date_Time DATETIME,

    Location VARCHAR(100),

    Capacity INT,

    Instructor_ID INT,

    Course_ID CHAR(6),

    FOREIGN KEY(Instructor_ID) REFERENCES Instructor(Instructor_ID),

    FOREIGN KEY(Course_ID) REFERENCES Course(Course_ID)

);

CREATE TABLE Enrollment(

    Section_ID CHAR(6),

    Student_ID INT,

    Enroll_Date DATE,

    Final_Grade CHAR(2),

    PRIMARY KEY(Section_ID, Student_ID),

    FOREIGN KEY(Section_ID) REFERENCES Section(Section_ID),

    FOREIGN KEY(Student_ID) REFERENCES Student(Student_ID)

);

Step-3:

-- data file is not provided, so here I am providing syntax of INSERT INTO statement

INSERT INTO table_name(column1_name, column2_name, ....) VALUES(column1_value column2_value, ....);

Step-4:

SELECT * FROM Zipcode;

SELECT * FROM Student;

SELECT * FROM Instructor;

SELECT * FROM Course;

SELECT * FROM Section;

SELECT * FROM Enrollment;

Step-5:

DESCRIBE Zipcode;

DESCRIBE Student;

DESCRIBE Instructor;

DESCRIBE Course;

DESCRIBE Section;

DESCRIBE Enrollment;

SHOW CREATE TABLE Zipcode;

SHOW CREATE TABLE Student;

SHOW CREATE TABLE Instructor;

SHOW CREATE TABLE Course;

SHOW CREATE TABLE Section;

SHOW CREATE TABLE Enrollment;

Add a comment
Know the answer?
Add Answer to:
The lab for this week addresses taking a logical database design (data model) and transforming it...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create the database and tables for the database. Show all SQL statements. Include primary and foreign...

    Create the database and tables for the database. Show all SQL statements. Include primary and foreign keys. Insert data into each table. Show select statements and display the output of each table. Note:Student’s name must be inserted into table as part of the data! Perform the SQL below: Query one table and use WHERE to filter the results. The SELECT clause should have a column list, not an asterisk (*). State the purpose of the query; show the query and...

  • Complete the following using Microsoft® SQL Server® 2016: Write SQL scripts in Microsoft® SQL Server® for...

    Complete the following using Microsoft® SQL Server® 2016: Write SQL scripts in Microsoft® SQL Server® for OLTP that include: A Data Definition Language (DDL) script creating the four tables with appropriate data types, primary and foreign keys Data Manipulation Language (DML) scripts that insert a minimum of five records into each table Select scripts showing the full contents of each table Write and run a test script for Step Two. Save a screenshot of the results. Create a 6-page Technical...

  • Help In Database: Next comes the data entry: Make up data for your database, or find...

    Help In Database: Next comes the data entry: Make up data for your database, or find real data. You can enter the data with INSERT statements, but it is much easier to use PhpAdmin. It has a form where you can type the data directly. Alternatively, you can use PhpAdmin to import CSV data (comma-separated values), which you can export from Excel. Include at least 3 rows in each of the entity relations, and as many rows as you need...

  • Write Ten SQL SELECT statements to query the STUDENT schema you created for practice lab. 4....

    Write Ten SQL SELECT statements to query the STUDENT schema you created for practice lab. 4. List all cities that have 10 or more students and instructors combined. Show city, state, number of student residents, number of instructor residents, and total student/instructor residents in that city. Sort by total in descending order. 5. List the instructor id and name of the instructors that teach fewer than 10 sections. 7. Find how many students are enrolled in sections taught by Todd...

  • Tables: Create table Item(                 ItemId                 char(5) constraint itmid_unique primar

    Tables: Create table Item(                 ItemId                 char(5) constraint itmid_unique primary key,                 Decription           varchar2(30),                 Unitcost               number(7,2)); Create table Customer(                 custID                   char(5) constraint cid.unique primary key,                 custName          varchar2(20),                 address                                varchar2(50)); Create table Orderdata( orderID                char(5) constraint oid_uniq primary key,                 orderdate           date,                 shipdate              date,                 ItemId                  char(5) references Item.ItemId,                 No_of_items     number(4),                 Unitcost               number(7,2),                 Order_total        number(7,2),                 custID                   char(5) references customer.custID); Insert Into Item values(‘A123’,’Pencil’,2.5); Insert Into Item values(‘B123’,’Pen’,15); Insert Into...

  • Learning Objectives: Learn to define constraints on tables Lean to define primary keys and foreign keys...

    Learning Objectives: Learn to define constraints on tables Lean to define primary keys and foreign keys Exercise                                                                                In Lab 09, we will continue the practice of creating tables. You will need to write SQL statements for the tasks specified below. After you complete them, submit your SQL script (in one *.sql file) to Blackboard by 11:59pm Nov. 16 (Friday). Include your name as a comment in the SQL script submitted. The creation statement for each table is worth one point,...

  • Use MySQL Workbench for these questions. Do NOT use Lucidchart. MySQL Workbench has more capability than...

    Use MySQL Workbench for these questions. Do NOT use Lucidchart. MySQL Workbench has more capability than Lucidchart, as it allows creation of DDL SQL from the model. Turn in 1 Workbench file , 1 document with the forward-engineered sql statements, and a Word document with your inserted data. This problem mimics the one from the previous assignment. Model it in Workbench, then forward-engineer the database script and import into your database. If the import fails, fix it in the model,...

  • 1. Create a PL/SQL program block that determines the top students with respect to GPA. Assume...

    1. Create a PL/SQL program block that determines the top students with respect to GPA. Assume that the database has four tables. Student(SSN, SName, DOB, Major) , Grade(SSN, CNo, Grade(0,1,2,3,4)) and Course table(CNo,CName, Credit Hour), Prerequisite(CNo, PreCNo); Student and couse data ae given in the following SQL statements a. Accept a number n as user input with SQL*Plus telling top n%. b. In a loop get the SName and GPA of the top n% people with respect to GPA. c....

  • im currently working on an sql database homework for a fundamentals class but im not too...

    im currently working on an sql database homework for a fundamentals class but im not too sure if my results are alright and would like to compare results, the assignment is as follows: O4pk,fk evaluate de data models, the specifications and table contents: equipment_tb Assigned_Equipment_tb workers_tb pk serial_number int pk,fk serial number int pk worker_id int, Surrogate brand char(10) worker id int Lastname char(100) model char(15) assigned_date date Firstname char(50) processor char(15) department int processor_velocity number (3,2) email char(200) memory...

  • Through the remaining assignments due in this course, you will be creating a simple database for...

    Through the remaining assignments due in this course, you will be creating a simple database for tracking information about volunteers working and raising money for a community organization. This assignment requires that you create the initial table, called PERSON, to hold basic information about volunteers. You will be redefining the design and building the database in the upcoming unit assignments. 1.Use the mysqldump.exe command line tool to backup the data in your volunteer database. To access the mysqldump.exe tool, start...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT