Question

In: Computer Science

Subject (DBA) use MYSQL workbench select my guitar shop database as default schema Question text Problem10...

Subject (DBA)

use MYSQL workbench select my guitar shop database as default schema

Question text

Problem10

Write a script that implements the following design in a database named household_chores:

Details

  • Include a statement to drop the database if it already exists.
  • Include statements to create and select the database.
  • Include any indexes that you think are necessary.
  • Specify the utf8 character set for all tables.
  • Specify the InnoDB storage engine for all tables.

Solution

______ DATABASE IF EXISTS ______ ;

CREATE DATABASE household_chores CHARSET _________ ;

________ ;

______   _______ (

         person_id       INT          PRIMARY KEY ______ ,

         first_name    VARCHAR(50) NOT NULL,

         last_name     VARCHAR(50) NOT NULL

) ENGINE = InnoDB;

CREATE TABLE chores (

         chore_id   INT         PRIMARY KEY _______

         name VARCHAR(100) UNIQUE

) _______

CREATE TABLE tasks (

         task_id   INT         PRIMARY KEY AUTO_INCREMENT,

         chore_id INT,

         name   _______ UNIQUE,

         CONSTRAINT fk_tasks_chores

                 _________

                 REFERENCES _______

) _______ = InnoDB;

CREATE TABLE assignments (

         _______    INT         PRIMARY KEY AUTO_INCREMENT,

         person_id   ______ ,

         task_id   INT,

         _______ fk_assignments_people

                 _______

                 REFERENCES _______ ,

         CONSTRAINT fk_assignments_tasks

                 ______

                 _______ tasks (task_id)

_______

Solutions

Expert Solution

The answers for blanks as follows :


DROP DATABASE IF EXISTS household_chores;
CREATE DATABASE household_chores CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE people (
    person_id INT PRIMARY KEY AUTO_INCREMENT,
    first_name VARCHAR(50) NOT NULL,
    last_name  VARCHAR(50) NOT NULL,
)ENGINE = innoDB;

CREATE TABLE chores(
    chore_id INT PRIMARY KEY AUTO_INCREMENT,
    name VARCHAR(100) UNIQUE
)ENGINE = innoDB;

CREATE TABLE tasks(
    task_id INT PRIMARY KEY AUTO_INCREMENT,
    chore_id INT,
    name VARCHAR(100) UNIQUE,
    CONSTRAINT fk_tasks_chores 
    FOREIGN KEY(chore_id)
    REFERENCES chores(chore_id)
)ENGINE = innoDB;

CREATE TABLE assignments(
    chore_id INT PRIMARY KEY AUTO_INCREMENT,
    person_id INT,
    task_id INT,
    CONSTRAINT fk_assignment_people
    FOREIGN KEY(person_id)
    REFERENCES people(person_id),
    CONSTRAINT fk_assignment_tasks
    FOREIGN KEY(task_id)
    REFERENCES tasks(task_id)
)ENGINE = innoDB;

 

Related Solutions

subject DBA use mysql workbench and select my guitar shop database as default schema Problem8 Write...
subject DBA use mysql workbench and select my guitar shop database as default schema Problem8 Write a script that implements the following design in a database named my_web_db:     users                                                       downloads                                                                 Products *user_id INT                                         * download_id INT                                                   * product_id INT                      *email_address VARCHAR(100)          * user_id INT                                                         * product_name VARCHAR(45) *first_name VARCHAR(45)                  *download_date DATETIME *last_name VARCHAR(45)                  * filename VARCHAR(50)                                                                *product_id INT Details In the downloads table, the user_id and product_id columns are the foreign keys. Include a statement to drop the...
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...
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...
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...
Subject DataBase/MySQL What is wrong with this statement? SELECT vendor_id, (SELECT vendor_name FROM vendors), avg(invoice_total) FROM...
Subject DataBase/MySQL What is wrong with this statement? SELECT vendor_id, (SELECT vendor_name FROM vendors), avg(invoice_total) FROM invoices GROUP BY vendor_id; Select one: a. The subquery returns more than 1 row. b. You need a JOIN ON clause to pull from multiple tables. c. You cannot have a subquery in the SELECT statement. d. The result is a Cartesian Product. e. There is nothing wrong with this statement. What is wrong with this statement? SELECT vendor_name, avg(invoice_total) AS 'Invoice Total' FROM...
Please create the SQL queries using the lryics database under question 4 and use "select *...
Please create the SQL queries using the lryics database under question 4 and use "select * from..." after each query to show the effects of your data manipulation query. Thanks for help 1. The title 'Time Flies' now has a new track, the 11th track 'Spring', which is 150 seconds long and has only a MP3 file. Insert the new track into Tracks table (Don’t hand-code any data for insert that can be looked up from the Titles table). 2....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT