HOW to create these tables in SQL? im using postgresql
Consider the following bank database schema:
branch(branch name, branch city, assets)
customer(ID, customer name, customer street, customer city)
loan(loan number, branch name, amount)
borrower(ID, loan number)
account(account number, branch name, balance)
depositor(ID, account number)
Solution for the given question are as follows -
1) branch
CREATE TABLE branch (
branch_name VARCHAR(50) PRIMARY KEY,
branch_city VARCHAR(50) NOT NULL,
assets VARCHAR(500)
);
2) customer
CREATE TABLE customer (
ID serial PRIMARY KEY,
customer_name VARCHAR(50) NOT NULL,
customer_street VARCHAR(50) NOT NULL,
customer_city VARCHAR(50) NOT NULL
);
3) loan
CREATE TABLE loan (
ID serial PRIMARY KEY,
loan_number integer(50) NOT NULL,
branch_name VARCHAR(50) NOT NULL,
amount integer(10) NOT NULL
);
4) borrower
CREATE TABLE borrower (
ID serial PRIMARY KEY,
loan_number integer(50) REFERENCES loan(loan_number)
);
5) account
CREATE TABLE account (
account_number serial PRIMARY KEY,
branch_name VARCHAR(50) REFERENCES branch(branch_name),
balance integer(50)
);
6) depositor
CREATE TABLE depositor (
ID serial PRIMARY KEY,
account_number serial REFERENCES account(account_number)
);
Get Answers For Free
Most questions answered within 1 hours.