Create a view of the Join of Deposit and Withdraw transactions to Bank Branch UNION with the join of Bill Payment and Debit Purchase, or Return transactions to Merchant (i.e., all transactions with appropriate reference name.).  BranchNbr stores RefNbr of either 'D', OR 'W' transactions, and MerchantNbr stores RefNbr of either 'B', 'P', or 'R' transactions. GIVEN THE BELOW: --THIS CREATES THE TRANSACTION TABLE:   CREATE TABLE Transaction (        TxNbr INT PRIMARY KEY,        AccountNbr INT,        TxTypeCode VARCHAR(250),        TxDate DATE,        TxTime TIMESTAMP,        TxAmount FLOAT,        RefNbr INT,        FOREIGN KEY (AccountNbr)REFERENCES Account(AccountNbr),        FOREIGN KEY (TxTypeCode) REFERENCES TxType(TxTypeCode));  --THIS CREATES THE BANK BRANCH TABLE: CREATE TABLE BankBranch (      BranchNbr INT PRIMARY KEY,      BranchName VARCHAR(250)); --THIS CREATES THE MERCHANT TABLE: CREATE TABLE Merchant (      MerchantNbr INT PRIMARY KEY,      MerchantName VARCHAR(250)); -- Insert test data into TxType table INSERT INTO TxType (TxTypeCode, TxTypeDescription) VALUES (‘D’, ‘DEPOSIT’); INSERT INTO TxType (TxTypeCode, TxTypeDescription) VALUES (‘W’, ‘WITHDRAWAL’); INSERT INTO TxType (TxTypeCode, TxTypeDescription) VALUES (‘P’, ‘PURCHASE’); INSERT INTO TxType (TxTypeCode, TxTypeDescription) VALUES (‘R’, ‘RETURN’); INSERT INTO TxType (TxTypeCode, TxTypeDescription) VALUES (‘B’, ‘BILL PAYMENT’); BRANCH     Nbr Name   101 … make up your own name 102 … make up your own name 103 … make up your own name 104 … make up your own name             MERCHANT     Nbr Name   301 … make up your own name 302 … make up your own name 303 … make up your own name 304 … make up your own name

A Guide to SQL
9th Edition
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Philip J. Pratt
Chapter2: Database Design Fundamentals
Section: Chapter Questions
Problem 15RQ
icon
Related questions
Question

Create a view of the Join of Deposit and Withdraw transactions to Bank Branch UNION with the join of Bill Payment and Debit Purchase, or Return transactions to Merchant (i.e., all transactions with appropriate reference name.). 

BranchNbr stores RefNbr of either 'D', OR 'W' transactions, and MerchantNbr stores RefNbr of either 'B', 'P', or 'R' transactions.

GIVEN THE BELOW:

--THIS CREATES THE TRANSACTION TABLE:  
CREATE TABLE Transaction (
       TxNbr INT PRIMARY KEY,
       AccountNbr INT,
       TxTypeCode VARCHAR(250),
       TxDate DATE,
       TxTime TIMESTAMP,
       TxAmount FLOAT,
       RefNbr INT,
       FOREIGN KEY (AccountNbr)REFERENCES Account(AccountNbr),
       FOREIGN KEY (TxTypeCode) REFERENCES TxType(TxTypeCode)); 

--THIS CREATES THE BANK BRANCH TABLE:
CREATE TABLE BankBranch (
     BranchNbr INT PRIMARY KEY,
     BranchName VARCHAR(250));

--THIS CREATES THE MERCHANT TABLE:
CREATE TABLE Merchant (
     MerchantNbr INT PRIMARY KEY,
     MerchantName VARCHAR(250));

-- Insert test data into TxType table

INSERT INTO TxType (TxTypeCode, TxTypeDescription)

VALUES (‘D’, ‘DEPOSIT’);

INSERT INTO TxType (TxTypeCode, TxTypeDescription)

VALUES (‘W’, ‘WITHDRAWAL’);

INSERT INTO TxType (TxTypeCode, TxTypeDescription)

VALUES (‘P’, ‘PURCHASE’);

INSERT INTO TxType (TxTypeCode, TxTypeDescription)

VALUES (‘R’, ‘RETURN’);

INSERT INTO TxType (TxTypeCode, TxTypeDescription)

VALUES (‘B’, ‘BILL PAYMENT’);

BRANCH    
Nbr Name  
101 … make up your own name
102 … make up your own name
103 … make up your own name
104 … make up your own name
     
     
MERCHANT    
Nbr Name  
301 … make up your own name
302 … make up your own name
303 … make up your own name
304 … make up your own name
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Intermediate SQL concepts
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
A Guide to SQL
A Guide to SQL
Computer Science
ISBN:
9781111527273
Author:
Philip J. Pratt
Publisher:
Course Technology Ptr
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage