Question

HOW to create these tables in SQL? im using postgresql Consider the following bank database schema:...

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)

Homework Answers

Answer #1

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)

);

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
DATABASE QUESTION Draw a schema diagram for the following database schema. Branch (branch_name, branch_city, assets) customer...
DATABASE QUESTION Draw a schema diagram for the following database schema. Branch (branch_name, branch_city, assets) customer (customer_name, customer_street, customer_city) loan (loan number, branch_name, amount) borrower (customer_name, loan_number) account (account_number, branch_name, balance) depositor (customer_name, account_number) Considering the schema above, write relational expressions for the following sentences 1.Find all loan numbers with a loan value greater than $15,000. 2.Find the names of all depositors who have an account with a value greater than $8,000. 3.Find the names of all depositors who have...
1. In SQL. Given the following relational database schema . The primary key is underlined. All...
1. In SQL. Given the following relational database schema . The primary key is underlined. All attributes are of type string if not indicated otherwise.  branch(branch_name,branch_city,assets: integer)  customer(customer_i,customer_name,customer_street,customer_city)  account(account_number,branch_name,balance)  depositor(customer_id,account_number) a. Find the names of customers that have accounts in every branch in Miami. b. Find the names of customers who do not have an account. (assume the bank keeps the customer information even if the account is closed.)
Consider the following set of requirement for a BANK database. Then draw an ER diagram based...
Consider the following set of requirement for a BANK database. Then draw an ER diagram based the requirement. The database keeps track of each back’s name, routing number, address. Banks has bank branch (you could name the relationship as BRANCHES). The bank branch described as branch name, branch location and branch ID. The branch ID is unique for each bank, but not unique in general. Users open account in bank branches. The accounts described by account number, account type, account...
Created the database and all the tables in phpMyadmin. In addition, write all the sql statements...
Created the database and all the tables in phpMyadmin. In addition, write all the sql statements used in perforing the tasks in a word document and submit that for grading. Lab 1: CREATE STATEMENT This statement is used to create a database or a table. CREATE DATABASE This statement is used to create a database Syntax: CREATE DATABASE database_name; OR CREATE SCHEMA database_name; Example: CREATE DATABASE Nyumbani; OR CREATE SCHEMA Nyumbani ; CREATE TABLE This SQL statement is used to...
Write a script to create the following tables with attributes as specified(SQL) Customer table with Customer’s...
Write a script to create the following tables with attributes as specified(SQL) Customer table with Customer’s id, name, address, city as varchar, customer’s date of birth as date type and zip code number where the customers id is the primary key in the table, name and date of birth are mandatory. Id has a 10-character limit, name, address and city have a 50-character limit, zip has a 5-character limit Product Table with Product id, description and finish as varchar, price...
You are hired to design a database for a fitness center. As the fitness center is...
You are hired to design a database for a fitness center. As the fitness center is expanding with more than one branch, they want to create a database to keep track of its customers, facilities and employees. Each branch has a unique id and address (building number, street, district, and city). A branch may have more than one facility (e.g. swimming pool, spa, etc.). Each facility must belong to only one branch, and the information for a facility is name...
Write a SQL statement for the following query: Relational Schema: Part( P #, PName, Producer, Year,...
Write a SQL statement for the following query: Relational Schema: Part( P #, PName, Producer, Year, Price) (P# is the primary key) Customer( C#, CName, City) (C# is the primary key) Supply(S#, P#, C#, Quantity, Amount, Date) (S# is the primary key) Query: For each Apple product supplied to more than 10 different customers in Chicago in 2020, list product number, product name, total supply quantity, and total supply amount. Sort the result by product name.
. Design an ER-diagram for a bank that implements the following requirements. The database you design...
. Design an ER-diagram for a bank that implements the following requirements. The database you design should store information about customers, accounts, branches and employees • Customer: Customers are identified by their SSN. For each customer we store a name, multiple phone numbers (one or more), and an occupation. • Account: Accounts are identified by an account number and the branch they belong to. For each account we store a balance and the type of account (e.g., savings). – An...
Give the relational algebra, tuple calculus, and SQL expressions for each using the below schema: SPERSON(EmpID,...
Give the relational algebra, tuple calculus, and SQL expressions for each using the below schema: SPERSON(EmpID, Name, Dept) TRIP(TripID, EmpID, ToCity, StartDate, EndDate) EXPENSE(ExpID, TripID, AccountID, Amount) a) List the names and employee ID of a salesperson. b) List employee ID and employee names that took a trip(s) to Charleston city. c) List the names of all employees who have spent more than $500 on their trip. d) List employees' names and their IDs that have never taken a trip....
1. Consider the following tables in a relational database. Provide the appropriate "SELECT" SQL statement necessary...
1. Consider the following tables in a relational database. Provide the appropriate "SELECT" SQL statement necessary to answer the queries that follow. Primary keys are underlined and foreign key fields have an asterisk at the end of the field. CUSTOMERS (CUST-NO, C-NAME, C-ADDRESS, BALANCE) SALESPERSONS (SP-NO, S-NAME, DATE-EMPLOYED, SALARY) SALES (INVOICE-NO, DATE, CUST-NO*, SP-NO*) a) List the salesperson name and salary for all sales to customers whose balance outstanding is greater than 20000. b) List the names and addresses of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT