0% found this document useful (0 votes)
5 views

Create The Following Tables

Uploaded by

Irfan Sharif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Create The Following Tables

Uploaded by

Irfan Sharif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Create the following tables:

Branch (branch-id, branch-name, customer-city)

Customer (customer-id, customer-name, customer-city, branch-id)

(a) Create a form to accept the data from the user with appropriate validation
checks.

(b) Generate queries to do the following:????


CREATE TABLE Branch (
branch_id INT PRIMARY KEY,
branch_name VARCHAR(255),
customer_city VARCHAR(255)
);

CREATE TABLE Customer (


customer_id INT PRIMARY KEY,
customer_name VARCHAR(255),
customer_city VARCHAR(255),
branch_id INT,
FOREIGN KEY (branch_id) REFERENCES Branch(branch_id)
);
(i) List all those customers who have more than 100 customers.????
SELECT b.branch_name, COUNT(c.customer_id) AS num_customers
FROM Branch b
JOIN Customer c ON b.branch_id = c.branch_id
GROUP BY b.branch_name
HAVING COUNT(c.customer_id) > 100;
List all those customers who have an account in more than one branch.????
SELECT c.customer_name
FROM Customer c
GROUP BY c.customer_name
HAVING COUNT(DISTINCT c.branch_id) > 1;

You might also like