Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CREATE TABLE People ( PID SERIAL, pName VARCHAR(50), pGender CHAR(1), pHeight FLOAT, PRIMARY KEY (PID) ); CREATE TABLE Accounts ( AID SERIAL, PID INT, aDate

CREATE TABLE People ( PID SERIAL, pName VARCHAR(50), pGender CHAR(1), pHeight FLOAT, PRIMARY KEY (PID) );

CREATE TABLE Accounts ( AID SERIAL, PID INT, aDate DATE, aBalance INT, aOver INT, PRIMARY KEY (AID), FOREIGN KEY (PID) REFERENCES People(PID) );

CREATE TABLE AccountRecords ( RID SERIAL, AID INT, rDate DATE, rType CHAR(1), rAmount INT, rBalance INT, PRIMARY KEY (RID), FOREIGN KEY (AID) REFERENCES Accounts(AID) );

CREATE TABLE Bills ( BID SERIAL, PID INT, bDueDate DATE NOT NULL, bAmount INT, bIsPaid BOOLEAN NOT NULL, PRIMARY KEY (BID), FOREIGN KEY (PID) REFERENCES People(PID) );

a.) Create a view AllAccountRecords that joins the Accounts and AccountRecords and shows one entry for each record for each account. The view should show all columns from both tables, first Accounts and then AccountRecords, except the AccountRecords.AID column. Accounts with no entry in AccountRecords should be shown with NULLs in the columns for AccountRecords.

b.) Create a view DebtorStatus that shows, for each person whose total balance is less than 0, the PID and pName of the person, the total balance of all their accounts, and the total overdraft of all their accounts.

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_2

Step: 3

blur-text-image_3

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

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions