I am getting an error about an existing constraint with the borrower_fkey for the borrower relation. At the same time, I feel like I have not satisfied all the requirements. Could someone show me what I did wrong?
I am getting an error about an existing constraint with the borrower_fkey for the borrower relation. At the same time, I feel like I have not satisfied all the requirements. Could someone show me what I did wrong?
I am getting an error about an existing constraint with the borrower_fkey for the borrower relation. At the same time, I feel like I have not satisfied all the requirements. Could someone show me what I did wrong?
I am getting an error about an existing constraint with the borrower_fkey for the borrower relation. At the same time, I feel like I have not satisfied all the requirements. Could someone show me what I did wrong?
The class is being taught using PostgreSQL so the changes have to be applicable to postgreSQL.
Transcribed Image Text:2. Consider the bank database schema given below, where the primary keys are underlined.
Write the SQL DDL corresponding to this schema (i.e. the CREATE TABLE statements).
Make any reasonable assumptions about the data types. Be sure to declare primary and
foreign keys; both types of constraints should be given appropriate names. Correctly and
appropriately implement at least one instance for each of the following: check constraint,
not null constraint, on delete cascade clause, on update cascade clause, and a default
value statement. Lastly, construct the following SQL queries for this relational database.
NOTE THE FOLLOWING: You are free to define the DDL for this banking database as
you wish, provided that the above requirements are satisfied. However, there is one
prohibition: You must not include a foreign key constraint on the account number
attribute of the depositor relation that references the account relation. To be perfectly
clear, this means you must not include the following foreign key constraint in your DDL:
CREATE TABLE depositor
CONSTRAINT depositor_fkey FOREIGN KEY (account_number)
REFERENCES account (account number)
ON DELETE CASCADE
ON UPDATE CASCADE
);
The reason for this specific foreign key prohibition concerns question (3) of this
assignment. The spirit behind question (3) is to write a trigger that performs the same
action that is accomplished by the ON DELETE CASCADE clause of the above foreign
So, if you were to include this foreign key constraint with the ON
key constraint.
DELETE CASCADE clause in your DDL, then the trigger you must define in question (3)
would be useless since the action would be performed not by the trigger - but, rather by
the ON DELETE
CASCADE clause instead. If you were to include this foreign key
constraint without the ON DELETE CASCADE clause in your DDL, then the DBMS
would disallow you from deleting any tuples from the account relation. If you include the
specified foreign key constraint in your DDL, you will receive a grade of zero for
question (3).
Database Schema:
branch ( branch_name, branch_city, assets )
customer ( ID, customer_name, customer_street, customer_city )
loan (loan mиmber, branch пате, атоиnt)
borrower ( ID, loan number )
ассоunt (аccount mumber, branch_name, balance)
depositor ( ID. account_number )
Note that in the following problem, there is only one bank, and the individual branches
listed in the data are all owned by the one bank.
Data for this bank database can be found on Brightspace. You may, of course, add more
data if it aids you in testing queries.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.