Question

In: Computer Science

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 the tables and make sure the contents of the tables match below.  

Write and execute the SQL to insert three records ProductID 844, 555 and 645 to the Product table (see below)

Write and execute the SQL to insert the one record to the Stock table (see below).  

2. Write and execute the SQL select statements to do the following selections of ALL TUPLES IN A TABLE

a. Select all (attributes) tuples in Product

b. Select all (attributes) tuples in Manufacturer

c. Select all (attributes) tuples in Stock

3. Write and execute the SQL select statements to do the following selections of ONLY SOME TUPLED IN A TABLE

a. Select Manufacturer ID = 1 tuples in Product table.

b. Select ProductID of Products that have a quantity of 300.

c. Select ProductID of Products that have quantity of 300 and less.

4. Write and execute the SQL select statements that select attributes (not all) based on a condition.

a. Select ProductID for items with ManufacturerID of 4.

b. Select ProductName for items with ManufacturerID of 1.

c. Select Products with the productName 'Keyboard'

5. Write and execute the SQL select statements that SELECT with and without DISTINCT modifier

a. Select ProductName and ManufacturerID from Product

b. Select Product Name and ManufacturerID from Product with the Distinct modifier.

c. Explain the difference in the results from a and b.

Solutions

Expert Solution

Please rate the answer. Feel free to contact me in case of any more clarifications required.

Note: I don't have the stock table structure. So I have not given the insert sql for the stock table.

Please comment me the stock table columns. I will add the insert statement.

Question_1. First insert tuples into two of the tables and make sure the contents of the tables match below.  

        Write and execute the SQL to insert three records ProductID 844, 555 and 645 to the Product table (see below)
        Answer => INSERT INTO Product (Productid,manufactureid,quantity,name) VALUES (844,112,20,'Monitor');  
                          INSERT INTO Product (Productid,manufactureid,quantity,name) VALUES (555,122,25,'Mouse');
                          INSERT INTO Product (Productid,manufactureid,quantity,name) VALUES (645,132,30,'Keyboard');

        Write and execute the SQL to insert the one record to the Stock table (see below).  
        Answer => 
 
Question_2. Write and execute the SQL select statements to do the following selections of ALL TUPLES IN A TABLE
        a. Select all (attributes) tuples in Product
        Answer => SELECT * FROM PRODUCT;
        
        b. Select all (attributes) tuples in Manufacturer
        Answer => SELECT * FROM MANUFACTURER;

        c. Select all (attributes) tuples in Stock
        Answer => SELECT * FROM STOCK;
Question_3. Write and execute the SQL select statements to do the following selections of ONLY SOME TUPLED IN A TABLE
        a. Select Manufacturer ID = 1 tuples in Product table.
        Answer => SELECT * FROM PRODUCT WHERE MANUFACTUREID = 1;

        b. Select ProductID of Products that have a quantity of 300.
        Answer => SELECT ProductID FROM PRODUCT WHERE QUANTITY = 300;

        c. Select ProductID of Products that have quantity of 300 and less.
        Answer => SELECT ProductID FROM PRODUCT WHERE QUANTITY <= 300;
Question_4. Write and execute the SQL select statements that select attributes (not all) based on a condition.
        a. Select ProductID for items with manufactureid of 4.
        Answer => SELECT ProductID FROM PRODUCT WHERE MANUFACTUREID = 4;

        b. Select ProductName for items with manufactureid of 1.
        Answer => SELECT ProductID FROM PRODUCT WHERE MANUFACTUREID = 1;

        c. Select Products with the productName 'Keyboard'
        Answer => SELECT * FROM PRODUCT WHERE name = 'Keyboard';
Question_5. Write and execute the SQL select statements that SELECT with and without DISTINCT modifier
        a. Select ProductName and manufactureid from Product
        Answer => SELECT Name as "Product Name", MANUFACTUREID  FROM PRODUCT;

        b. Select Product Name and manufactureid from Product with the Distinct modifier.
        Answer => SELECT distinct Name as "Product Name", MANUFACTUREID  FROM PRODUCT;       

        c. Explain the difference in the results from a and b.
           DISTINCT will remove those rows where all the selected fields are identical. 
           So in Question_5 a, the result will show all the records from the table PRODUCT
           Question_5 b, will only show the distinct records from the product i.e. the records are not identical..

The explanation for Question_5.


Related Solutions

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...
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);...
Homework Arrays and Tables In this assignment you are to create an algorithm, flowchart, and pseudocode...
Homework Arrays and Tables In this assignment you are to create an algorithm, flowchart, and pseudocode for a solution of the following problem. This solution will include the use of arrays needed to complete all parts of the logic. You have requested to develop a program that will record and process the rainfall totals of a 12 month period. You would use an array to store each months total. Once all 12 months amounts are entered then your solution need...
JAVA PROGRAMMING. In this assignment, you are to create a class named Payroll. In the class,...
JAVA PROGRAMMING. In this assignment, you are to create a class named Payroll. In the class, you are to have the following data members: name: String (5 pts) id: String   (5 pts) hours: int   (5 pts) rate: double (5 pts) private members (5 pts) You are to create no-arg and parameterized constructors and the appropriate setters(accessors) and getters (mutators). (20 pts) The class definition should also handle the following exceptions: An employee name should not be empty, otherwise an exception...
DROP DATABASE class;CREATE DATABASE class;Use class;drop table if exists Class;drop table if exists Student;CREATE TABLE Class...
DROP DATABASE class;CREATE DATABASE class;Use class;drop table if exists Class;drop table if exists Student;CREATE TABLE Class (CIN int PRIMARY KEY, FirstName varchar(255), LastName varchar(255), Gender varchar(1), EyeColor varchar(50), HairColor varchar(50), HeightInches int,CurrentGrade varchar(1));CREATE TABLE Student (SSN int PRIMARY KEY,FirstName varchar(255),LastName varchar(255), Age int,BirthMonth varchar(255),HeightInches int,Address varchar(255),City varchar(255),PhoneNumber varchar(12),Email varchar(255),FavColor varchar(255),FavNumber int);INSERT INTO Class VALUES(1, "David", "San", "M", "BRN", "BLK", 72, "-");INSERT INTO Class VALUES(2, "Jeff", "Gonzales", "M", "BRN", "BLK", 68, "B");INSERT INTO Class VALUES(3, "Anna", "Grayson", "F", "BRN", "BRN", 62,...
Ingles Corporation is a manufacturer of tables. The table tops are manufactured by Ingles, but the...
Ingles Corporation is a manufacturer of tables. The table tops are manufactured by Ingles, but the table legs are purchased from an outside supplier. The Assembly Department takes a manufactured table top and attaches the four purchased table legs. It takes 16 minutes of labor to assemble a table. The company follows a policy of producing enough tables to ensure that 40 percent of next month’s sales are in the current month’s finished goods inventory. Ingles also purchases sufficient materials...
Ingles Corporation is a manufacturer of tables. The table tops are manufactured by Ingles, but the...
Ingles Corporation is a manufacturer of tables. The table tops are manufactured by Ingles, but the table legs are purchased from an outside supplier. The Assembly Department takes a manufactured table top and attaches the four purchased table legs. It takes 16 minutes of labor to assemble a table. The company follows a policy of producing enough tables to ensure that 40 percent of next month’s sales are in the current month’s finished goods inventory. Ingles also purchases sufficient materials...
Ingles Corporation is a manufacturer of tables. The table tops are manufactured by Ingles, but the...
Ingles Corporation is a manufacturer of tables. The table tops are manufactured by Ingles, but the table legs are purchased from an outside supplier. The Assembly Department takes a manufactured table top and attaches the four purchased table legs. It takes 16 minutes of labor to assemble a table. The company follows a policy of producing enough tables to ensure that 40 percent of next month’s sales are in the current month’s finished goods inventory. Ingles also purchases sufficient materials...
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...
java For this assignment, you will create a Time class that holds an hour value and...
java For this assignment, you will create a Time class that holds an hour value and a minute value to represent a time. We will be using "military time", so 12:01 AM is 0001 and 1 PM is 1300. For this assignment, you may assume valid military times range from 0000 to 2359. Valid standard times range from 12:00 AM to 11:59 PM. In previous assignments, we had a requirement that your class be named Main. In this assignment, the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT