Question

In: Computer Science

I can't imagine how much more info you require to answer this. It is MySQL if...

I can't imagine how much more info you require to answer this. It is MySQL if that helps but even that info is here. If you don't know how to answer, then don't. There is more information here than anyone should need to answer the questions.

The structure and contents of the Ch08_SimpleCo database are shown in Figure P8.16. Use this database to answer the following problems. Database Schema The schema for the Ch08_SimpleCo database is shown below and should be used to answer the next several problems. Click this image to view it in its own tab.

Instructions

Given the structure of the Ch08_SimpleCo database shown above, use SQL commands to answer the problems in the following steps.

Write your SQL statement in the editor on the right, then click the Run Query button to execute your statement in the interactive MySQL shell.

Problem 18

Write the set of SQL commands necessary to insert the data into the CUSTOMER table you created in Problem 16, as illustrated in Figure P8.16.

My code: INSERT INTO CUSTOMER VALUES(1,"bhavana","wali",12345678.45);

My error: ERROR 1062 (23000) at line 1: Duplicate entry '1' for key 'PRIMARY'

18.a

Write the set of SQL commands necessary to insert the data into the INVOICE table you created in Problem 17, as illustrated in Figure P8.16.

Use YYYY-MM-DD format when inserting dates.

my code: INSERT INTO INVOICE VALUES(11,'2015/12/1',12312388.12,1);

my error: ERROR 1062 (23000) at line 1: Duplicate entry '11' for key 'PRIMARY'

18.b

Using MySQL, populate the CUST_LNAME, CUST_FNAME, and CUST_BALANCE fields with the following customers:

CUST_LNAME CUST_FNAME CUST_BALANCE
Smith Jeanne 1050.11
Ortega Juan

840.92

my code:

INSERT INTO CUST_MYSQL(CUST_LNAME,CUST_FNAME,CUST_BALANCE) VALUES ("Smith","Jeanne",1050.11);
INSERT INTO CUST_MYSQL(CUST_LNAME,CUST_FNAME,CUST_BALANCE) VALUES ("Ortega","Juan",840.920);

SELECT * FROM CUSTOMER;
SELECT * FROM INVOICE;
SELECT * FROM CUST_MYSQL;

My results:

CUST_NUM CUST_FNAME CUST_LNAME CUST_BALANCE
1 bhavana wali 12345678.45
INV_NUM INV_DATE INV_AMOUNT CUST_NUM
11 2015-12-01 12312388.12 1
CUST_NUM CUST_FNAME CUST_LNAME CUST_BALANCE CUST_DOB
2000 Smith Jeanne 1050.11 NULL
2001 Ortega Juan 840.92 NULL
2002 Jeanne Smith 1050.11 NULL
2003 Juan Ortega 840.92 NULL

the results I need:

SELECT * FROM CUST_MYSQL

Expected Results

CUST_NUM CUST_LNAME CUST_FNAME CUST_BALANCE
2000 Smith Jeanne 1050.11
2001 Ortega Juan 840.92

18.c

Populate the CUST_NUM, INV_DATE, and INV_AMOUNT fields with the following customers:

CUST_NUM INV_DATE INV_AMOUNT
1000 2016-03-23 235.89
1001 2016-03-23 312.82
1001 2016-03-30 528.10
1000 2016-04-12 194.78
1000 2016-04-23 619.44

my code:

insert into INVOICE(CUST_NUM , INV_DATE, INV_AMOUNT)
values(1000,'2016-03-23', 235.89), (1001, '2016-03-23', 312.82),
(1001, '2016-03-30', 528.10), (1000, '2016-04-12', 194.78), (1000, '2016-04-23', 619.44);

select * from INVOICE;

My error:

ERROR 1364 (HY000) at line 1: Field 'INV_NUM' doesn't have a default value

18.d

Insert the following customer into the CUST_MYSQL table, allowing the AUTO_INCREMENT attribute set up in Problem 20.a and Problem 20.b to generate the customer number automatically:

CUST_LNAME CUST_FNAME CUST_BALANCE
Powers Ruth 500

my code:

insert into CUSTOMER(CUST_LNAME, CUST_FNAME, CUST_BALANCE)
values('Powers', 'Ruth', 500);

select * from CUSTOMER;

my error:

ERROR 1364 (HY000) at line 1: Field 'CUST_NUM' doesn't have a default value

18.e

Modify the CUSTOMER table to include the customer’s date of birth (CUST_DOB), which should store date data

my code:

insert into CUSTOMER(CUST_LNAME, CUST_FNAME, CUST_BALANCE)
values('Powers', 'Ruth', 500);

select * from CUSTOMER;

my error:

ERROR 1364 (HY000) at line 1: Field 'CUST_NUM' doesn't have a default value

18.f

Modify customer 1000 to indicate the date of birth on March 15, 1989.

Use YYYY-MM-DD format for inserting dates.

my code:

UPDATE CUST_MYSQL SET CUST_DOB='1989-03-15' WHERE CUST_NUM=1000;

my results state "NO DATA"

ERROR 1054 (42S22) at line 1: Unknown column 'CUST_DOB' in 'field list'

The wrong headers were returned.

Some expected rows were missing (shown in red below).

Test Query

SELECT CUST_NUM, CUST_DOB FROM CUSTOMER WHERE CUST_NUM = 1000

Expected Results

CUST_NUM CUST_DOB
1000 1989-03-15

18.g

Problem 25

Modify customer 1001 to indicate the date of birth on December 22, 1988.

Use YYYY-MM-DD format for inserting dates.

my code:

ALTER TABLE CUSTOMER ADD(DOB DATE);
UPDATE CUSTOMER SET DOB='1988-12-22' WHERE CUST_NUM=1001;
Select * from Customer;

My error:

ERROR 1146 (42S02) at line 3: Table 'Ch08_SimpleCo.Customer' doesn't exist

Help! Talk to me like I'm really stupid. Thank you.

Solutions

Expert Solution

Problem 18 In the CUSTOMER table, CUST_NUM is primary key. Error is coming as one record is already present with the Primary key 1

18.a In the INVOICE table, INV_NUM is primary key. Error is coming as one record is already present with the primary key 11

18.b In the CUST_MYSQL table, there are four records present. If you want to see only first two records and the desired columns then you can use the limit clause. Also, the query should be like


select CUST_NUM, CUST_LNAME, CUST_FNAME, CUST_BALANCE from CUST_MYSQL limit 2

18.c In the Invoice table, you are only passing values for CUST_NUM , INV_DATE, INV_AMOUNT columns. But INV_NUM is the primary key and it is not set to auto increment so you can not miss the value. So, in order to avoid this error you have to pass value for INV_NUM also.

18.d, 18.e In the CUSTOMER table, as CUST_NUM is the primary key. You have to pass the value for primary key. Because primary key can not be null or duplicate.

18.f Reason for the error is that you might not have added the column CUST_DOB in to the CUST_MYSQL table. First alter the table add the column CUST_DOB and then try the same query, It will work fine.

18.g Correct syntax for adding a new column in mysql is
ALTER TABLE table_name
ADD column_name datatype;

So, if you follow this syntax, new column will be added and you will not see errors.


Related Solutions

How should I answer this question if I can't remember my dreams For a few days,...
How should I answer this question if I can't remember my dreams For a few days, record your dreams first thing in the morning. Discuss what is going on in your life related to your dream as further evidence that our dream activity is further processing of relevant information.
Please answer all If you can't answer all then please don't answer just one question. i...
Please answer all If you can't answer all then please don't answer just one question. i need all 2. You would like to buy a house in in 16 years and estimate that you will need a deposit of $73,014. You plan to make bi-weekly deposits into an account that you hope will earn 7.05%. How much do you have to deposit every two weeks? 3. You have accumulated $1,085.55 in debt by buying things on Amazon during quarantine.  The minimum...
********I NEED THE BELL SHAPED CURVE, PLEASE DON'T ANSWER IF YOU CAN'T INCLUDE*********** ********I NEED THE...
********I NEED THE BELL SHAPED CURVE, PLEASE DON'T ANSWER IF YOU CAN'T INCLUDE*********** ********I NEED THE BELL SHAPED CURVE, PLEASE DON'T ANSWER IF YOU CAN'T INCLUDE*********** ********I NEED THE BELL SHAPED CURVE, PLEASE DON'T ANSWER IF YOU CAN'T INCLUDE*********** ********I NEED THE BELL SHAPED CURVE, PLEASE DON'T ANSWER IF YOU CAN'T INCLUDE*********** According to the Organization for Economic Co-Operation and Development (OECD), adults in the United States worked an average of 1,805 hours in 2007. Assume the population standard deviation...
please answer if you know or suggest any right info is there an app where i...
please answer if you know or suggest any right info is there an app where i can keet track of its inventory and provides me with its barcode for my items (creating) -i have a store and plan to use my phone as a bar reader and keep track of its inventory when i sell something as it will automatically adjust itself. so that way i can go to just one place which is the whole point!!! i dont care...
Please use EXCEL to answer and show all formulas. I can't understand the answer if I...
Please use EXCEL to answer and show all formulas. I can't understand the answer if I can't see the formulas for each field. Thank you very much. Newman manufacturing is considering a cash purchase of the stock of Grips Tool. During the year just​ completed, Grips earned $4.25 per share and paid cash dividends of ​$2.55 per share ​(D0=$2.55). Grips' earnings and dividends are expected to grow at 25​% per year for the next 3​ years, after which they are...
I understand this question has 7 ones following it so if you can't produce the answer...
I understand this question has 7 ones following it so if you can't produce the answer a.-g. can you please at least leave the formulas? You have just been hired as a loan officer at San Diego State Bank. Your supervisor has given you a file containing a request from Mobile Company, a manufacturer of auto components, for a $1,000,000 five-year loan. Financial statement data on the company for the last two years are given below: Mobile Company Comparative Balance...
Please if you can't write 500 words do not answer i need 500 words for this...
Please if you can't write 500 words do not answer i need 500 words for this assignment. Step 1 Consider a time when you wanted to buy a certain product but could not find it. What was your reaction? Why? How did the lack of availability affect your perception of the company and of the product? Did it make you want it more or did it make you frustrated so that you lost interest. Speculate on the supply chain and...
If you require a 12% rate of return, how much would you pay now for a...
If you require a 12% rate of return, how much would you pay now for a bond with a face value of $6,000, pays $160 interest each year and matures in 10 years' time? (Round your answer to the nearest $10). $2,840 $2,850 $2,860 $2,870 None of the above Eclipse Textile Company Ltd generated an EPS this year of $4.30 and paid a dividendof $1.65 per share. Eclipse Textile Company has recently been able to generate a return of 13.50%...
Please, explain your answer, i am here to learn. Pass it if you can't explain all...
Please, explain your answer, i am here to learn. Pass it if you can't explain all the answer to others out there. and be fair. Thanks. 1. Which one of the following is true about the power of the project managers in different organizational structures? a. In a project-oriented organization, the project manager has no real authority and power. b. A strong matrix maintains many characteristics of a project-oriented organization, where much of the authority rests with the project manager....
I have tried this multiple times and I can't get the right answer. The 2014 balance...
I have tried this multiple times and I can't get the right answer. The 2014 balance sheet of Jordan’s Golf Shop, Inc., showed long-term debt of $5.2 million, and the 2015 balance sheet showed long-term debt of $5.45 million. The 2015 income statement showed an interest expense of $170,000. The 2014 balance sheet showed $520,000 in the common stock account and $5.5 million in the additional paid-in surplus account. The 2015 balance sheet showed $560,000 and $5.7 million in the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT