Question

In: Computer Science

Tables: Create table Item(    &nbs... Bookmark Tables: Create table Item(                 ItemId           &nb

Tables:

Create table Item(    &nbs...

Bookmark

Tables:

Create table Item(

                ItemId                 char(5) constraint itmid_unique primary key,

                Decription           varchar2(30),

                Unitcost               number(7,2));

Create table Customer(

                custID                   char(5) constraint cid.unique primary key,

                custName          varchar2(20),

                address                                varchar2(50));

Create table Orderdata(

orderID                char(5) constraint oid_uniq primary key,

                orderdate           date,

                shipdate              date,

                ItemId                  char(5) references Item.ItemId,

                No_of_items     number(4),

                Unitcost               number(7,2),

                Order_total        number(7,2),

                custID                   char(5) references customer.custID);

Insert Into Item values(‘A123’,’Pencil’,2.5);

Insert Into Item values(‘B123’,’Pen’,15);

Insert Into Customer(‘C123’,’ABC Gen stores’,’Sanfransico’);

Insert Into Customer(‘C132’,’XYZ stores’,’California’);

Insert into Orderdata(‘o123’,’12-aug-2016’,’12-aug-2016’,’A123’,5,2.5,12.5,’c123’);

Insert into Orderdata(‘o124’,’14-aug-2016’,’14-aug-2016’,’B123’,5,15,75,’c132’);

_____________________________________________________________

Enhance your Module 5 CT database table structures, via your selected RDBMS, as you wish.

, using SQL and an SQL script file, create and execute advanced queries of your choice that demonstrate each of the following:

The use of a GROUP BY clause, with a HAVING clause, and one or more group functions

The use of UNION operator

The use of a subquery

The use of an outer join

Then create and execute at least one SQL UPDATE and at least one SQL DELETE query.

Finally, create and use an SQL view and in a SELECT query.

Submit the following outputs of your SQL script file processing, in this order and appropriately labeled, in a single Word file:

The SQL and results of your INSERT statements to further populate your tables

The SQL and results of your 4 advanced SELECT queries

The SQL and results of your UPDATE and DELETE queries

The SQL and results of your view creation and its use in a SELECT query

You must show all of your SQL as it executed in Management Studio or other development environments. This includes the results returned by your selected RDBMS.

(((((((((((Note)))))))))))))))): you must populate any other tables and show the execution of your SQL statements as required.

Use a SELECT statement using the UNION operator.

create a view and use it in a SELECT query...

Solutions

Expert Solution

Execute in Oracle PLSQL Developer

--1. The use of a GROUP BY clause, with a HAVING clause, and one or more group functions
--This query returns the list of items whose cost is more than 2
select    Description,Unitcost from Item group by Description,Unitcost having Unitcost >=2;

--2 The use of UNION operator
--This query fetches all the records with columns ItemID,Unitcost in Item table and Orderdata table
select ItemId,Unitcost from Item
union
select ItemId,Unitcost from Orderdata

---3 The use of a subquery
---this query will fetch all the orderdata info whose has maximum Cost
select * from Orderdata where Unitcost in (select max(Unitcost) from Item);

--4 The use of an outer join
--this query fetches all records along with their description of items.
select a.*,b.Decription from Orderdata a
LEFT OUTER JOIN Item b
ON a.ItemId =b.ItemId

---5 Then create and execute at least one SQL UPDATE and at least one SQL DELETE query.
--this sql statement updates the unit cost of the pencil item to 3.
UPDATE Item
set Unitcost=3
where ItemId='A123'
--delete orderdata of particular customer in Orderdata table
delete from Orderdata where custID ='C123'

---View

--this view fetches the orders done on curent date

create or replace view VW_OrderDetails as

select orderID,orderdate,shipdate,ItemId,No_of_items,Unitcost,Order_total,custID where

to_date(orderdate)= sysdate;

Usage of view:

select * from VW_OrderDetails ;


Related Solutions

Write CREATE TABLE and INSERT INTO statements in order to create and populate five tables in...
Write CREATE TABLE and INSERT INTO statements in order to create and populate five tables in Oracle’s SQL*Plus.The information you need about the database ARE IN THE CHARTS BELOW. Each worksheet includes the following information about its associated table: ➢ Column names (for example, the jr_order table contains the orderID, customerID, orderDate, orderStatus, and orderShippedDate columns); ➢ Column data types (for example, orderID is INT, orderStatus is VARCHAR2(2), etc.); ➢ Column constraints, if any (for example, orderID in the jr_order...
Write create table statements to create tables for the Exoproduct employees computers database depicted by the...
Write create table statements to create tables for the Exoproduct employees computers database depicted by the relational schema created in a mini case MC5 in chapter 3. Use insert into statements to insert no fewer than 2 and no more than 10 records per table.
For this assignment you have to create tables as reviewed in class Manufacturer table, Product table...
For this assignment you have to create tables as reviewed in class Manufacturer table, Product table and Stock table. The code is in Week 7 PPT lecture. You are to add update as needed to make the tables the same as below and match Product, Manufacturer and Stock as below. For this assignment you will be working with these same tables.   Please complete the following tasks and submit in word file or notepad. 1. First insert tuples into two of...
For this assignment you have to create tables as reviewed in class Manufacturer table, Product table...
For this assignment you have to create tables as reviewed in class Manufacturer table, Product table and Stock table. The code is in Week 7 PPT lecture. You are to add update as needed to make the tables the same as below and match Product, Manufacturer and Stock as below. For this assignment you will be working with these same tables.   Please complete the following tasks and submit in word file or notepad. 1. First insert tuples into two of...
Create a query in Access that uses two tables, the Patient table and the Session table. Add
Create a query in Access that uses two tables, the Patient table and the Session table. Add the LastName, FirstName, and SessionDate fields to the query grid. Run the query. How many records are displayed? Delete the join line between the field lists in Query Design View. Rerun the query. How many records are now displayed? Why are the results different? You do not need to save the queries. 
Create a table in SQL with foreign key reference: 1.Create the three tables without any columns...
Create a table in SQL with foreign key reference: 1.Create the three tables without any columns 2.Alter the tables to add the columns 3.Alter the tables to create the primary and foreign keys
Table Rock Tables, manufactures two popular tables, a country style table and a contemporary style table....
Table Rock Tables, manufactures two popular tables, a country style table and a contemporary style table. The manufacturing process for both tables requires the use of three types of machines. The time to produce the tables on each machine given in the following table: Machine   Country Table Contemporary Table Total Time Available Router 1.5 2 1000 Sander 3.0 4.5 2000 Polisher 2.5 1.5 1500 The earns a profit of $350 on the Country table, and $450 on the Contemporary table....
Complete the following table: Ppm                 Grams                     &nbs
Complete the following table: Ppm                 Grams                         Air Volume (l)            Mol. Wt. (g) _______        0.02542                           75                               339 2                    0.00228                          300 _____ 1000                7.164 _____ 146 0.002 _____ 2650 254
Create table, create primary and foreign key constraints. Create index on the table to satisfy a...
Create table, create primary and foreign key constraints. Create index on the table to satisfy a query with aggregate functions.
Bank Balance Sheet (Note: Use this information for all three problems) Item                             Amount  &nb
Bank Balance Sheet (Note: Use this information for all three problems) Item                             Amount            Duration       Interest Rate        Cash-type Securities       $50m                1.2 year             2.25% Commercial Loans          $100m             2.4 years           4.50% Mortgages                     $350m             8.0 years           6.50% Core Deposits                $270m             1.0 year             2.00% Notes Payable                $180m             2.0 years           4.50% 2. On-Balance Sheet Immunization Analysis (Use balance sheet information above, 6 points) Immunization formulas: 1) Setting DA x A = DL x L will immunize...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT