Database Systems: Design, Implementation, & Management
Database Systems: Design, Implementation, & Management
11th Edition
ISBN: 9781285196145
Author: Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher: Cengage Learning
Question
Book Icon
Chapter 8, Problem 18RQ
Program Plan Intro

(a)

UNION set operator:

The UNION set operator is used to combine the output of two or more than two queries and produce a result. The produced result contains unique values.

Syntax:

QUERY UNION QUERY;

Consider two tables:

Table creation:

CREATE TABLE VENDOR(VEND_CODE INT PRIMARY KEY);

CREATE TABLE PRODUCT(PROD_CODE VARCHAR(5), VEND_CODE INT,FOREIGN KEY (VEND_CODE) REFERENCES VENDOR (VEND_CODE));

Inserting values:

INSERT INTO VENDOR VALUES(123);

INSERT INTO VENDOR VALUES(124);

INSERT INTO VENDOR VALUES(125);

INSERT INTO VENDOR VALUES(126);

INSERT INTO PRODUCT VALUES('ABC', 125);

INSERT INTO PRODUCT VALUES('DEF', 124);

INSERT INTO PRODUCT VALUES('GHI', 124);

INSERT INTO PRODUCT VALUES('JKL', 123);

Program Plan Intro

(b)

UNION ALL set operator:

The UNION ALL set operator is used to combine the output of two or more than two queries and produce a result. The produced result contains duplicate values.

Syntax:

QUERY UNION ALL QUERY;

Consider two tables:

Table creation:

CREATE TABLE VENDOR(VEND_CODE INT PRIMARY KEY);

CREATE TABLE PRODUCT(PROD_CODE VARCHAR(5), VEND_CODE INT,FOREIGN KEY (VEND_CODE) REFERENCES VENDOR (VEND_CODE));

Inserting values:

INSERT INTO VENDOR VALUES(123);

INSERT INTO VENDOR VALUES(124);

INSERT INTO VENDOR VALUES(125);

INSERT INTO VENDOR VALUES(126);

INSERT INTO PRODUCT VALUES('ABC', 125);

INSERT INTO PRODUCT VALUES('DEF', 124);

INSERT INTO PRODUCT VALUES('GHI', 124);

INSERT INTO PRODUCT VALUES('JKL', 123);

Program Plan Intro

(c)

INTERSECT set operator:

The INTERSECT set operator is used to combine the output of two or more than two queries and produce a result. The produced result contains the values (rows) that are common in both the tables.

Syntax:

QUERY INTERSECT QUERY;

Consider two tables:

Table creation:

CREATE TABLE VENDOR(VEND_CODE INT PRIMARY KEY);

CREATE TABLE PRODUCT(PROD_CODE VARCHAR(5), VEND_CODE INT,FOREIGN KEY (VEND_CODE) REFERENCES VENDOR (VEND_CODE));

Inserting values:

INSERT INTO VENDOR VALUES(123);

INSERT INTO VENDOR VALUES(124);

INSERT INTO VENDOR VALUES(125);

INSERT INTO VENDOR VALUES(126);

INSERT INTO PRODUCT VALUES('ABC', 125);

INSERT INTO PRODUCT VALUES('DEF', 124);

INSERT INTO PRODUCT VALUES('GHI', 124);

INSERT INTO PRODUCT VALUES('JKL', 123);

Program Plan Intro

(d)

EXCEPT/ MINUS set operator:

The MINUS set operator is used to combine the output of two or more than two queries and produce a result. The produced result contains the values (rows) that appear in the first table but not in the second table. The word “EXCEPT” can also be used in the place of “MINUS”.

Syntax:

QUERY EXCEPT QUERY;

Consider two tables:

Table creation:

CREATE TABLE VENDOR(VEND_CODE INT PRIMARY KEY);

CREATE TABLE PRODUCT(PROD_CODE VARCHAR(5), VEND_CODE INT,FOREIGN KEY (VEND_CODE) REFERENCES VENDOR (VEND_CODE));

Inserting values:

INSERT INTO VENDOR VALUES(123);

INSERT INTO VENDOR VALUES(124);

INSERT INTO VENDOR VALUES(125);

INSERT INTO VENDOR VALUES(126);

INSERT INTO PRODUCT VALUES('ABC', 125);

INSERT INTO PRODUCT VALUES('DEF', 124);

INSERT INTO PRODUCT VALUES('GHI', 124);

INSERT INTO PRODUCT VALUES('JKL', 123);

Blurred answer
Students have asked these similar questions
Answer the given question with a proper explanation and step-by-step solution.  c. Create a relastionship: You need to add a new column called DeptID in the Employee table, it will be the foreign key in this table, it should be text data type and 5 characters in length. Make sure you enter one of the corresponding departmentID's values (i.e., ECON, MIS, and BUS) for this column in the Employee table for this newly created DeptId column that you have entered in the Department table previously. Then, use the Relationships tool under Database Tools to create a relationship between the Department Table and the Employee table, i.e., connecting the two tables together via the primary key (DepartmentID in Department Table) and foreign key pair (DeptID in the Employee Table and choose Enforce Referential Integrity to set the integrity contraint between the foreign key and primary key
Convert the following table to third normal form (3NF). In this table, StudentNum determines StudentName, NumCredits, AdvisorNum, and AdvisorName. Advisor Num determines AdvisorName. CourseNum determines Description. The combination of StudentNum and CourseNum determines Grade. STUDENT (StudentNum, StudentName, NumCredits, AdvisorNum, AdvisorName, CourseNum, Description, Grade). Identify the primary key for the original table and the primary keys for the resulting tables. Indicate the foreign keys with italic font. Give meaning names to the resulting tables.
Suppose that the following are true:- all id column are primary keys in whichever table they are- the dept_id in course table is foreign key that is referencing the id column in the department table- the foreign keys stud_type_id, stud_cat_id in the student table are referencing the id columnsin the student_type and student_category tables respectively.- the coursecode and stud_id columns in the registration table are foreign keys in the courseand student tables respectively.1. Design an Entity Relationship Diagram for the system above.2. Write query that would return the names and contacts of all Local students.3. Write a query that would return names, contact and locations of all departments that has alocation text with Ave 3 as part of it. [hint: use the LIKE clause with “_” or “%”]4. What would be the result returned for the following query:SELECT first_name, last_name, student_type.name,student_category.nameFROM student, student_type, student_categoryWHERE stud_type_id =…

Chapter 8 Solutions

Database Systems: Design, Implementation, & Management

Ch. 8 - Prob. 11RQCh. 8 - Prob. 12RQCh. 8 - Prob. 13RQCh. 8 - Given the employee information in Question 11,...Ch. 8 - Prob. 15RQCh. 8 - Prob. 16RQCh. 8 - Prob. 17RQCh. 8 - Prob. 18RQCh. 8 - What string function should you use to list the...Ch. 8 - Prob. 20RQCh. 8 - Prob. 21RQCh. 8 - Prob. 22RQCh. 8 - Prob. 23RQCh. 8 - Prob. 24RQCh. 8 - Prob. 1PCh. 8 - Insert the data into the tables you created in...Ch. 8 - Prob. 3PCh. 8 - Prob. 4PCh. 8 - Prob. 5PCh. 8 - Prob. 6PCh. 8 - Prob. 7PCh. 8 - Prob. 8PCh. 8 - Prob. 9PCh. 8 - Modify the CUSTOMER table to include two new...Ch. 8 - Prob. 11PCh. 8 - Prob. 12PCh. 8 - Prob. 13PCh. 8 - Prob. 14PCh. 8 - Prob. 15PCh. 8 - Prob. 16PCh. 8 - Write a trigger to update the customer balance...Ch. 8 - Write a procedure to delete an invoice, giving the...Ch. 8 - Prob. 19PCh. 8 - Prob. 20PCh. 8 - Prob. 21PCh. 8 - Prob. 22PCh. 8 - Prob. 23PCh. 8 - Prob. 24PCh. 8 - Prob. 25PCh. 8 - Prob. 26PCh. 8 - Prob. 27PCh. 8 - Create a trigger named trg_line_total to write the...Ch. 8 - Create a trigger named trg_line_prod that...Ch. 8 - Create a stored procedure named prc_inv_amounts to...Ch. 8 - Create a procedure named prc_cus_balance_update...Ch. 8 - Modify the MODEL table to add the attribute and...Ch. 8 - Prob. 33PCh. 8 - Modify the CHARTER table to add the attributes...Ch. 8 - Write the sequence of commands required to update...Ch. 8 - Write the sequence of commands required to update...Ch. 8 - Write the command required to update the...Ch. 8 - Write the command required to update the...Ch. 8 - Write the command required to update the...Ch. 8 - Prob. 40PCh. 8 - Create a trigger named trg_char_hours that...Ch. 8 - Create a trigger named trg_pic_hours that...Ch. 8 - Create a trigger named trg_cust_balance that...Ch. 8 - Alter the DETAILRENTAL table to include a derived...Ch. 8 - Alter the VIDEO table to include an attribute...Ch. 8 - Update the VID_STATUS attribute of the VIDEO table...Ch. 8 - Alter the PRICE table to include an attribute...Ch. 8 - Prob. 48CCh. 8 - Prob. 51C
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781285196145
Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:Cengage Learning