Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Tables for the Assignment Create the following tables in a database named roster. Make sure that your database and tables are named exactly as follows

Tables for the Assignment
Create the following tables in a database named "roster". Make sure that your database and tables are named exactly as follows including matching case.
DROP TABLE IF EXISTS Member;
DROP TABLE IF EXISTS 'User';
DROP TABLE IF EXISTS Course;
CREATE TABLE 'User'
user_id INTEGER NOT NULL AUTO_INCREMENT,
name VARCHAR(128) UNIQUE,
PRIMARY KEY(user_id)
CREATE TABLE Course (
course_id INTEGER NOT NULL AUTO_INCREMENT,
title VARCHAR(128) UNIQUE,
PRIMARY KEY(course_id)
REATE TABLE Member
user_id INTEGER,
courseid INTEGER,
role INTEGER,
CONSTRAINT FOREIGN KEY (user_id) REFERENCES 'User' (user_id)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT FOREIGN KEY (course_id) REFERENCES Course (course_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (user_id, course_id)
ENGINE=InNODB CHARACTER SET=ut 88 ;
Note that we need to surround User with back-quotes (i.e. 'User' because it is a keyword in later versions of MySQL.
Course Data
You will normalize the following data (each user gets different data), and insert the following data items into your database, creating and linking all the foreign keys properly. Encode
instructor with a role of 1 and a learner with a role of 0.
Johnny, si106, Instructor
Amber, sile6, Learner
Havin, sile6, Learner
Kaelum, si106, Learner Tayyib, si106, Learner
Rubyn, si110, Instructor
Alekzander, si110, Learner
Emelia, si110, Learner Mikael, si110, Learner
Oonagh, si110, Learner
Peregrine, si206, Instructor
Annabella, si206, Learner
Tait, si206, Learner
Tarne, si206, Learner
You can test to see if your data has been entered properly with the following SQL statement.
You can test to see if your data has been entered properly with the following SQL statement.
SELECT 'User'. name, Course.title, Member. role
FROM "User" JOIN Member JOIN Course
ON 'User', user_id = Member.user_id AND Member.course_id = Course.course_id
ORDER BY Course.title, Member.role DESC, 'User'. name
The order of the data and number of rows that comes back from this query should be the same as above. There should be no missing or extra data in your query.
What Turn In
When you have the data all inserted, use phpMyAdmin to Export the data as follows:
Select the database (do not select a table within the database)
Select the Export Tab
Select "Custom - display all possible options"
Select "Save output to a file"
Set the format to JSON
Do not select "pretty print" the output
Leave everything else as default and run the export.
The output will be on a file named "roster.json" that should look like the following:
??****
Export to JSON plugin for PHPMyAdmin
@version 0.1
*/
// Database 'roster'
// roster.Course
[{"course_id":"6","title":"si106"},...}]
// roster.Member
[{"user_id":"1","course_id":"1","role":"1"},...}]
// roster.User
[{"user_id":"15", "name":"Areez"},...}]
It is a somewhat strange format - it is one bit of JSON for each table. You don't need to edit or even look at this file. Simply upload it above.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

What impact do third-party modifications have on the on warranty?

Answered: 1 week ago

Question

4.1 Explain multiple uses of job analysis in HR decisions.

Answered: 1 week ago