Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Each completely correct, and fairly acceptable (with a different execution/explain plan) query 10 points Preparatory steps: a) Given a QITEM table, from the QSALE DB,

Each completely correct, and fairly acceptable (with a different execution/explain plan) query 10 points Preparatory steps: a) Given a QITEM table, from the QSALE DB, copy its content into NEWITEM table. b) Make three unrelated but elementary changes (one record update, one new record insert, and one old record delete) making sure you do not leave any duplicates. Provide as many different ways (queries) using only plain SQL (no triggers, no Transact or PL/SQL etc.) to accomplish the following task: -compare the tables QITEM and NEWITEM to assess if they are now exactly the same or not. Notes: 1. Assuming potentially large tables select * from each will not be acceptable! 2. You can use ether SQL Server.

here is the database:

drop table qemp; drop table qdel; drop table qsale; drop table qdept; drop table qspl; drop table qitem; create table qitem (itemname varchar2(30) constraint qitem_itemname_pk primary key constraint qitem_itemname_nn not null, itemtype varchar2(8) constraint qitem_itemtype_nn not null, itemcolor varchar2(10)); create table qspl (splno number(3) constraint qspl_splno_pk primary key constraint qspl_splno_nn not null, splname varchar2(30) constraint qspl_splname_nn not null); create table qdept (deptname varchar2(10) constraint qdept_deptname_pk primary key constraint qdept_deptname_nn not null, deptfloor number(1) constraint qdept_deptfloor_nn not null, deptphone number(2) constraint qdept_deptphone_nn not null, empno number(2) constraint qdept_empno_nn not null); create table qsale (saleno number(4) constraint qsale_saleno_pk primary key constraint qsale_saleno_nn not null, saleqty number(3) constraint qsale_saleqty_nn not null, itemname varchar2(30) constraint qsale_itemname_fk references qitem(itemname) constraint qsale_itemname_nn not null, deptname varchar2(10) constraint qsale_deptname_fk references qdept(deptname) constraint qsale_deptname_nn not null); create table qdel (delno number(3) constraint qdel_delno_pk primary key constraint qdel_delno_nn not null, delqty number(3) constraint qdel_delqty_nn not null, itemname varchar2(30) constraint qdel_itemname_fk references qitem(itemname) constraint qdel_itemname_nn not null, deptname varchar2(10) constraint qdel_deptname_fk references qdept(deptname) constraint qdel_deptname_nn not null, splno number(3) constraint qdel_splno_fk references qspl(splno) constraint qdel_splno_nn not null); create table qemp (empno number(2) constraint qemp_empno_pk primary key constraint qemp_empno_nn not null, empfname varchar2(10) constraint qemp_empfname_nn not null, empsalary number(7) constraint qemp_empsalary_nn not null, deptname varchar2(10) constraint qemp_deptname_fk references qdept(deptname) constraint qemp_deptname_nn not null, bossno number(2) constraint qemp_bossno_fk references qemp(empno)); -- insert data to qitem INSERT INTO qitem VALUES ('boots-snakeproof', 'c', 'green'); INSERT INTO qitem VALUES ('camel saddle', 'r', 'brown'); INSERT INTO qitem VALUES ('compass', 'n', NULL); INSERT INTO qitem VALUES ('elephant polo stick', 'r', 'bamboo'); INSERT INTO qitem VALUES ('exploring in 10 easy lessons', 'b', NULL); INSERT INTO qitem VALUES ('geo positioning system', 'n', NULL); INSERT INTO qitem VALUES ('hammock', 'f', 'khaki'); INSERT INTO qitem VALUES ('hat-polar explorer', 'c', 'white'); INSERT INTO qitem VALUES ('how to win foreign friends', 'b', NULL); INSERT INTO qitem VALUES ('map case', 'e', 'brown'); INSERT INTO qitem VALUES ('map measure', 'n', NULL); INSERT INTO qitem VALUES ('pith helmet', 'c', 'khaki'); INSERT INTO qitem VALUES ('pocket knife-avon', 'e', 'brown'); INSERT INTO qitem VALUES ('pocket knife-nile', 'e', 'brown'); INSERT INTO qitem VALUES ('safari chair', 'f', 'khaki'); INSERT INTO qitem VALUES ('safari cooking kit', 'f', NULL); INSERT INTO qitem VALUES ('sextant', 'n', NULL); INSERT INTO qitem VALUES ('stetson', 'c', 'black'); INSERT INTO qitem VALUES ('tent-2 person', 'f', 'khaki'); INSERT INTO qitem VALUES ('tent-8 person', 'f', 'khaki'); -- insert data into qspl INSERT INTO qspl VALUES (101, 'global books '||'&'||' maps'); INSERT INTO qspl VALUES (102, 'nepalese corp.'); INSERT INTO qspl VALUES (103, 'all sports manufacturing'); INSERT INTO qspl VALUES (104, 'sweatshops unlimited'); INSERT INTO qspl VALUES (105, 'all points, inc.'); INSERT INTO qspl VALUES (106, 'sao paulo manufacturing'); -- insert data into qdept INSERT INTO qdept VALUES ('management', 5, 34, 1); INSERT INTO qdept VALUES ('books', 1, 81, 4); INSERT INTO qdept VALUES ('clothes', 2, 24, 4); INSERT INTO qdept VALUES ('equipment', 3, 57, 3); INSERT INTO qdept VALUES ('furniture', 4, 14, 3); INSERT INTO qdept VALUES ('navigation', 1, 41, 3); INSERT INTO qdept VALUES ('recreation', 2, 29, 4); INSERT INTO qdept VALUES ('accounting', 5, 35, 5); INSERT INTO qdept VALUES ('purchasing', 5, 36, 7); INSERT INTO qdept VALUES ('personnel', 5, 37, 9); INSERT INTO qdept VALUES ('marketing', 5, 38, 2); -- insert data into qsale INSERT INTO qsale VALUES (1001, 2, 'boots-snakeproof', 'clothes'); INSERT INTO qsale VALUES (1002, 1, 'pith helmet', 'clothes'); INSERT INTO qsale VALUES (1003, 1, 'sextant', 'navigation'); INSERT INTO qsale VALUES (1004, 3, 'hat-polar explorer', 'clothes'); INSERT INTO qsale VALUES (1005, 5, 'pith helmet', 'equipment'); INSERT INTO qsale VALUES (1006, 1, 'pocket knife-nile', 'clothes');

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago