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));

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 3 steps

Blurred answer
Knowledge Booster
SQL Query
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
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781305627482
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Database Systems: Design, Implementation, & Manag…
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