Question

In: Computer Science

Using the sample.sql script, create the sample database in MySQL. Submit the MySQL interactive screen that...

  1. 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 accttype (id, type) values (4,'visa');
insert into accttype (id, type) values (5,'debit');
insert into accttype (id, type) values (6,'home');
create table account (acctno int auto_increment primary key, custno int, type int, balance double, index acpair(acctno,custno), foreign key (custno) references customer(custno), foreign key (type) references accttype(id));
insert into customer (firstname,middle,lastname,address,telnum1,pin,email) values('John','Quincy','Adams','PO Box 1234, Allentown, PA 18101','6102561034','2564','[email protected]');
insert into customer (firstname,middle,lastname,address,telnum1,telnum2,pin,email) values('Richard','Milhouse','Nixon','120 Union Avenue, Bethlehem, PA 18018','6102111210','4843201457','9873','[email protected]');
insert into customer (firstname,middle,lastname,address,telnum1,telnum2,pin,email) values('David','Dwight','Eisenhower','34 Main Street, Folgelsville, PA 18025','6104561234','4849871200','63712','[email protected]');
insert into account (custno, type, balance) values (1,1,1356.75);
insert into account (custno, type, balance) values (1,2,10000.00);
insert into account (custno, type, balance) values (1,3,50000.00);
insert into account (custno, type, balance) values (1,4,129.13);
insert into account (custno, type, balance) values (1,5,0.0);
insert into account (custno, type, balance) values (2,1,121.19);
insert into account (custno, type, balance) values (2,2,8194.10);
insert into account (custno, type, balance) values (2,4,2015.99);
insert into account (custno, type, balance) values (2,5,0.0);
insert into account (custno, type, balance) values (3,2,563.00);
insert into account (custno, type, balance) values (3,3,20000.00);
insert into account (custno, type, balance) values (3,6,1000000.00);
create table checking (acctno int, custno int, primary key (acctno, custno), index acpair(acctno,custno), foreign key (acctno,custno) references account(acctno, custno));
insert into checking (acctno, custno) values (1,1);
insert into checking (acctno, custno) values (6,2);
create table saving (acctno int, custno int, apr double, primary key (acctno, custno), index acpair(acctno,custno), foreign key (acctno,custno) references account(acctno,custno));
insert into saving (acctno, custno, apr) values (2,1,0.25);
insert into saving (acctno, custno, apr) values (7,2,0.015);
insert into saving (acctno, custno, apr) values (10,3,0.005);
create table cd (acctno int, custno int, apr double, mature date, primary key (acctno, custno), index acpair(acctno,custno), foreign key (acctno,custno) references account(acctno,custno));
insert into cd (acctno, custno, apr, mature) values (3,1,0.05,'2020-09-10');
insert into cd (acctno, custno, apr, mature) values (11,3,0.045,'2020-12-31');
create table visa (acctno int, custno int, minpay double, due date, rate double, primary key (acctno, custno), index acpair(acctno,custno), foreign key (acctno,custno) references account(acctno,custno));
insert into visa (acctno, custno, minpay, due, rate) values (4,1,25.00,'2020-09-19',0.15);
insert into visa (acctno, custno, minpay, due, rate) values (8,2,25.00,'2020-09-21',0.15);
create table debit (acctno int, custno int, primary key (acctno, custno), index acpair(acctno,custno), foreign key (acctno,custno) references account(acctno,custno));
insert into debit (acctno, custno) values (5,1);
insert into debit (acctno, custno) values (9,2);
create table home (acctno int, custno int, payment double, due date, rate double, term int, primary key (acctno, custno), index acpair(acctno,custno), foreign key (acctno,custno) references account(acctno,custno));
insert into home (acctno, custno, payment, due, rate, term) values (12,3,3696.19,'2020-09-30',0.02,30);
# It is a good idea to do all further work with the sample database as a regular user
# as opposed to the root user. To get up yourself as a user, invoke the mysql command
# as the root user then enter at the mysql prompt:
# mysql> create user <yourID>@localhost identified by 'securepasswd';
# check to make sure this worked with:
# mysql> select user, host from mysql.user;
# Then give yourID permissions to use the sample DB:
# mysql> grant all privileges on sample.* to 'yourID'@'localhost';
# To verify, log into mysql with the command:
# $ mysql -u yourID -p
# and enter the password. When logged in enter:
# mysql use sample;
# To verify enter:
# mysql> show tables;

Solutions

Expert Solution

Creating user with name test and password testpass

Showing all the tables

I hope this will help.


Related Solutions

Using PHP and MYSQL and with a simple customer database, how can I create a simple...
Using PHP and MYSQL and with a simple customer database, how can I create a simple log in and registration system for an ecommerce site
Using MySQL 8.xx create a database with the following characteristics. . A. Your design MUST meet...
Using MySQL 8.xx create a database with the following characteristics. . A. Your design MUST meet the requirements for Third Normal Form B. Create a database (you will need multiple tables) to store employee information. This information will include: Employee Number, First Name, Last Name, Date of birth, Address, city, state, zip, department, job title, supervisor, health insurance number, health insurance provider, dental insurance number, dental insurance provider, spouse/partner, children, children's ages. C. Populate the table with multiple records which...
In MySql, using Application MYSQL Workbench and the Chinook database, please answer the following: -- 12....
In MySql, using Application MYSQL Workbench and the Chinook database, please answer the following: -- 12. SELECT the trackid, name and filesize (as shown in the bytes column) for all tracks that have a file size less than 2000000 and a GenreId of 1 or a file size less than 2000000 and a Genreid of 2 -- 13. Add a sort to the query from number 12 to sort by GenreID; -- 14. List all columns from the customer table...
Design Of Database System Course True or False 1. In MySQL, it is possible to create...
Design Of Database System Course True or False 1. In MySQL, it is possible to create a table by using the definition of another table. 2. {(t.lname) | s ∈ Student, s.stuId = t.stuId, t ∉ Graduate_Student, s.major = ‘CS’} is a safe relational calculus expression. 3. In SQL, it is possible to insert multiple rows into a table using a single INSERT statement.
Using WORKBENCH: 1. Create the database below via an ER Diagram in Workbench (take screen shots...
Using WORKBENCH: 1. Create the database below via an ER Diagram in Workbench (take screen shots of the diagram) 2. Go to the database table view and take a screen shot of the table(s) 3. Go to the data entry tool and enter at least three lines of data (in each table). Take screen shots. Create a database that is in third normal form for the following: You are a nerd and have decided to organize your comic books in...
The MySQL script provided in chapter 4 (murachs php & mysql) creates and populates the DB...
The MySQL script provided in chapter 4 (murachs php & mysql) creates and populates the DB used in this application(s). A look at the tables shows no connection between parent and child tables. Provide the necessary SQL for enforcing data integrity between tables: categories and products. JUST NEED SQL FOR ENFORCING ??
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...
Design and implement a relational database application of your choice using MS Workbench on MySQL a)...
Design and implement a relational database application of your choice using MS Workbench on MySQL a) Declare two relations (tables) using the SQL DDL. To each relation name, add the last 4 digits of your Student-ID. Each relation (table) should have at least 4 attributes. Insert data to both relations (tables); (15%) b) Based on your expected use of the database, choose some of the attributes of each relation as your primary keys (indexes). To each Primary Key name, add...
Create a simple web page with two(2) AJAX interactions with a mySQL Database AJAX 1 should...
Create a simple web page with two(2) AJAX interactions with a mySQL Database AJAX 1 should return HTML content for use on the page AJAX 2 should return JSON content for use on the page Use a JS library, such as jQuery, to ensure the AJAX works on all browsers
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT