Question

Use MySQL Workbench to do the two task, for each task, run and then take a...

Use MySQL Workbench to do the two task, for each task, run and then take a screenshot.

Task 1:

Example: You want to keep track of all the customers that live in area 615 and are issued more than 1 invoice. It has a long query!! How about putting it in the view.

CREATE VIEW CUSTOMERS_OF_615 AS SELECT CUSTOMER.CUS_CODE, COUNT(INV_NUMBER) AS INVOICE_COUNT FROM CUSTOMER JOIN INVOICE

USING (CUS_CODE)

WHERE CUSTOMER.CUS_AREACODE = 615

GROUP BY CUSTOMER.CUS_CODE HAVING INVOICE_COUNT >1

A VIEW can be fetched similar to a table.

SELECT * FROM CUSTOMERS_OF_615

Question: Create a View that displays each vendor’s contact information with the number of products they provide, take a screenshot!

Task 2:

Question:

Create a Trigger that will log changes in the Customer table after any update to a new table named as Customer_modified.

Test the Trigger using the query below:

UPDATE CUSTOMER SET CUS_INITIAL="ASD", CUS_AREACODE="123",

CUS_PHONE='1234', CUS_BALANCE='656' WHERE CUS_CODE=10011

0 0
Add a comment Improve this question Transcribed image text
Answer #1

TASK1:
CREATE VIEW CUSTOMERS_OF_615 AS SELECT CUSTOMER.CUS_CODE, COUNT(INV_NUMBER) AS INVOICE_COUNT FROM CUSTOMER JOIN INVOICE

USING (CUS_CODE)

WHERE CUSTOMER.CUS_AREACODE = 615

GROUP BY CUSTOMER.CUS_CODE HAVING INVOICE_COUNT >1

EXPLANATION: Yes, you are doing in right way

Add a comment
Know the answer?
Add Answer to:
Use MySQL Workbench to do the two task, for each task, run and then take a...
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
  • What would I have to write into the MySQL Workbench query to execute these commands? -...

    What would I have to write into the MySQL Workbench query to execute these commands? - Show all vendor information with vendor contact information in upper case like "SMITH". - Show the customer balance in total, in average, in minimized and in maximized value. - Show all customer information whose balance is greater than $500. - Aggregate the total cost of products grouped by V_CODE, and only show the records with total exceeds $500, and list the records in descending...

  • use workbench please Task 1: Create a database and name it practical2DB. (2 marks) Task 2:...

    use workbench please Task 1: Create a database and name it practical2DB. (2 marks) Task 2: Create all the four tables according to the relational scheme in Figure 1. (8 marks) Task 3: Insert 5 records to into each table. (5 marks) Task 4: Write a query to list alphabetically ordered names, addresses, and IDs of all the customers whose postcode is in (40150, 40400, 47500). (10 marks) Task 5: Delete 1 record from Products table using their primary keys....

  • Using the ch08_saleco database write a T-SQL query to display the customer code, invoice number invoice...

    Using the ch08_saleco database write a T-SQL query to display the customer code, invoice number invoice date, and invoice subtotal from invoice conditioned on the invoice subtotal is greater than $100 and from only customer codes 10011 and 10012. (hint: in) /* Database Systems, 8th Ed., Rob/Coronel */ /* Type of SQL : SQL Server */ CREATE TABLE CUSTOMER ( CUS_CODE int, CUS_LNAME varchar(15), CUS_FNAME varchar(15), CUS_INITIAL varchar(1), CUS_AREACODE varchar(3), CUS_PHONE varchar(8), CUS_BALANCE float(8) ); INSERT INTO CUSTOMER VALUES('10010','Ramas','Alfred','A','615','844-2573','0'); INSERT...

  • Create a stored procedure named prc_inv_amounts to update the INV_SUBTOTAL, INV_TAX, and INV_TOTAL. The procedure takes the invoice number as a parameter. The INV_SUBTOTAL is the sum of the LINE_TOTAL...

    Create a stored procedure named prc_inv_amounts to update the INV_SUBTOTAL, INV_TAX, and INV_TOTAL. The procedure takes the invoice number as a parameter. The INV_SUBTOTAL is the sum of the LINE_TOTAL amounts for the invoice, the INV_TAX is the product of the INV_SUBTOTAL and the tax rate (8 percent), and the INV_TOTAL is the sum of the INV_SUBTOTAL and the INV_TAX /* Database Systems, Coronel/Morris */ /* Type of SQL : SQL Server */ /* WARNING: */ /* WE HIGHLY RECOMEND...

  • Create SQL statements based on the given tables: Code to create the tables: CREATE DATABASE LAB...

    Create SQL statements based on the given tables: Code to create the tables: CREATE DATABASE LAB4DB; USE LAB4DB; CREATE TABLE CUSTOMER ( CUS_CODE int primary key, CUS_LNAME varchar(15), CUS_FNAME varchar(15), CUS_INITIAL varchar(1), CUS_AREACODE varchar(3), CUS_PHONE varchar(8), CUS_BALANCE float(8) ); INSERT INTO CUSTOMER VALUES('10010','Ramas','Alfred','A','615','844-2573','0'); INSERT INTO CUSTOMER VALUES('10011','Dunne','Leona','K','713','894-1238','0'); INSERT INTO CUSTOMER VALUES('10012','Smith','Kathy','W','615','894-2285','345.86'); INSERT INTO CUSTOMER VALUES('10013','Olowski','Paul','F','615','894-2180','536.75'); INSERT INTO CUSTOMER VALUES('10014','Orlando','Myron','','615','222-1672','0'); INSERT INTO CUSTOMER VALUES('10015','O''Brian','Amy','B','713','442-3381','0'); INSERT INTO CUSTOMER VALUES('10016','Brown','James','G','615','297-1228','221.19'); INSERT INTO CUSTOMER VALUES('10017','Williams','George','','615','290-2556','768.93'); INSERT INTO CUSTOMER VALUES('10018','Farriss','Anne','G','713','382-7185','216.55'); INSERT INTO CUSTOMER VALUES('10019','Smith','Olette','K','615','297-3809','0'); /*...

  • For this hands-on project, you will use the SQL Server named instance SQLSERVERHOA, and the HandsOnOne...

    For this hands-on project, you will use the SQL Server named instance SQLSERVERHOA, and the HandsOnOne database and tables you created in previous chapters. The objective of this activity is to practice generating keys and encrypting/decrypting data. Document each step by taking a screen shot of the Query Editor window after successfully executing each SQL query. 1.In SQL Server Management Studio, open a new Query Editor window, which you will use for completing all steps in this activity. 2.Create a...

  • * myCompany.SQL Introduction to SQL Script file for ORACLE DBMS This script file creates the following...

    * myCompany.SQL Introduction to SQL Script file for ORACLE DBMS This script file creates the following tables: VENDOR, PRODUCT, CUSTOMER, INVOICE, LINE EMPLOYEE and loads the default data rows */ set echo on; set serveroutput on; select systimestamp from dual; show user; ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY'; DROP TABLE LINE CASCADE CONSTRAINTS; DROP TABLE INVOICE CASCADE CONSTRAINTS; DROP TABLE CUSTOMER CASCADE CONSTRAINTS; DROP TABLE PRODUCT CASCADE CONSTRAINTS; DROP TABLE VENDOR CASCADE CONSTRAINTS; DROP TABLE EMPLOYEE CASCADE CONSTRAINTS; CREATE TABLE...

  • Question 1. For each table, identify the primary key and the foreign key(s). If a table...

    Question 1. For each table, identify the primary key and the foreign key(s). If a table does not have a foreign key, write None. Question 2. Do the tables exhibit entity integrity? Answer yes or no, and then explain your answer. Question 3. Do the tables exhibit referential integrity? Answer yes or no, and then explain your answer. Write NA (Not Applicable) if the table does not have a foreign key. Question 4. Describe the type(s) of relationship(s) between CUSTOMER...

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