Question

Space X Bank CREATE TABLE Branch(BranchIDNumber VARCHAR(15) PRIMARY KEY NOT NULL, BranchName VARCHAR(6) NOT NULL, Address...

Space X Bank


CREATE TABLE Branch(BranchIDNumber VARCHAR(15) PRIMARY KEY NOT NULL, BranchName VARCHAR(6) NOT NULL, Address VARCHAR(50) NOT NULL, City TEXT NULL,
State CHAR(2) NULL, ZipCode INT(11) NOT NULL, OfficeNum VARCHAR(15) NOT NULL, FaxNum VARCHAR(15) NOT NULL);

CREATE TABLE Employee(EmployeeIDNumber VARCHAR(15) NOT NULL,FirstName VARCHAR(35) NOT NULL, LastName VARCHAR(35) NOT NULL,
Email VARCHAR(100) NOT NULL, BranchIDNumber VARCHAR(11) NOT NULL, FOREIGN KEY(BranchIDNumber) REFERENCES Branch(BranchIDNumber),
JobTitle ENUM("Manager","Staff") NOT NULL, Salary DECIMAL(8, 2) NOT NULL, HomeNumber VARCHAR(13) NULL, CellNumber VARCHAR(13) NOT NULL);

CREATE TABLE Customer(CustomerIDNumber VARCHAR(15) PRIMARY KEY NOT NULL, FirstName VARCHAR(35) NOT NULL, LastName VARCHAR(35) NOT NULL, Address VARCHAR(35) NOT NULL,
City TEXT NOT NULL, State CHAR(2) NULL, ZipCode INT(10) NOT NULL, CellNumber VARCHAR(13) NOT NULL, Email VARCHAR(100) NOT NULL,
BranchIDNumber VARCHAR(11) NOT NULL, FOREIGN KEY(BranchIDNumber) REFERENCES Branch(BranchIDNumber));


CREATE TABLE Account(BAccountNumber VARCHAR(25) NOT NULL PRIMARY KEY, AccountBalance DECIMAL(8, 2) NOT NULL, CustomerIDNumber VARCHAR(15) NOT NULL, FOREIGN KEY(CustomerIDNumber)
REFERENCES Customer(CustomerIDNumber), EmployeeIDNumber VARCHAR(15) NOT NULL, FOREIGN KEY(EmployeeIDNumber) REFERENCES Employee(EmployeeIDNumber),
AccountType ENUM("Checking", "MoneyMarketSavings") NOT NULL, ExpirationDate DATE Not NULL,
CardType ENUM("Mastercard", "Other"));

CREATE TABLE Checking(BAccountNumber VARCHAR(25) NOT NULL, FOREIGN KEY (BAccountNumber) REFERENCES Account(BAccountNumber), OverDraftFee INT(2) NOT NULL);

CREATE TABLE MoneyMarketSavings(BAccountNumber VARCHAR(25) NOT NULL, FOREIGN KEY (BAccountNumber) REFERENCES Account(BAccountNumber), InterestRate DECIMAL(8, 3));

CREATE TABLE CreditCard(CreditCardNumber VARCHAR(25) PRIMARY KEY NOT NULL, SecurityCode INT(3) NOT NULL, FOREIGN KEY(SecurityCode) REFERENCES CreditCard(SecurityCode),
CurrentBalance DECIMAL(8,2) NOT NULL, ExpirationDate DATE NOT NULL, CardType ENUM("MasterCard", "Visa") NOT NULL, CreditLimit INT(15) NOT NULL, AnnualFee INT(3) NOT NULL,
LateFee INT(3) NOT NULL, CustomerIDNumber VARCHAR(15) NOT NULL, FOREIGN KEY(CustomerIDNumber) REFERENCES Customer(CustomerIDNumber));

CREATE TABLE CreditCardPayment(PaymentNumber VARCHAR(35) PRIMARY KEY NOT NULL, CreditCardNumber VARCHAR(35) NOT NULL, FOREIGN KEY (CreditCardNumber)
REFERENCES CreditCard(CreditCardNumber), PaymentDate DATE NOT NULL, PaymentAmount DECIMAL(8,2) NOT NULL,PaymentType ENUM("Cash", "Bank Transfer") NOT NULL);
_______________________

Retrieve queries:

5. Retrieve the credit card number, the current balance, card type and expiration date. Only show those whose current balance is under 2500 or the expiration date is from 12/01/2020 to 12/01/2021 Format the date to show as 10/14/2020 and format the current balance to show $2500

6. Retrieve the customer full name and email. In addition, show the customers account number, their balance, and account type. Only show those customers whose balance is over 5000 and are not Money Market Savings accounts.

7. Retrieve the money market savings account number, its interest rate, the account balance, show how much interest amount that was earned from every account. In addition apply that interest amount to a new column called new balance. Round the new balance to 2nd decimal place.

8. Retrieve the Customers Full name and their full address. Show how many accounts each customer has opened.

9. Retrieve the customer full name, and email. Also retrieve credit card number, current balance, expiration date and card type. Show the total amount of money paid for each account. IN addition, reduce that amount from the current balance and put it in a new column called new balance. Sort it by the customer full name Also format the date to show as 12/2020 and Current balance, total amount of money paid and new balance to show as $45,000.00

Homework Answers

Answer #1

SQL QUERIES:

1.

SELECT EmployeeIDNumber, FirstName, LastName

FROM Employee

WHERE BranchIDNumber= (SELECT BranchIDNumber FROM Branch WHERE BranchName= 'SpaceX');

2.

SELECT AccountNumber, AccountBalance, AccountType

FROM Account

WHERE AccountBalance BETWEEN 500 AND 1000;

3.

SELECT COUNT(EmployeeIDNumber) AS "Number of Employees"

FROM Employee

WHERE BranchIDNumber= 'SpaceX';

4.

SELECT AccountNumber

FROM Account

WHERE AccountBalance> 5000

AND AccountType= "Money Market Savings";

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
CREATE TABLE Customers (Customer# NUMBER(4), LastName VARCHAR2(10) NOT NULL, FirstName VARCHAR2(10) NOT NULL, Address VARCHAR2(20), City...
CREATE TABLE Customers (Customer# NUMBER(4), LastName VARCHAR2(10) NOT NULL, FirstName VARCHAR2(10) NOT NULL, Address VARCHAR2(20), City VARCHAR2(12), State VARCHAR2(2), Zip VARCHAR2(5), Referred NUMBER(4), Region CHAR(2), Email VARCHAR2(30), CONSTRAINT customers_customer#_pk PRIMARY KEY(customer#), CONSTRAINT customers_region_ck CHECK (region IN ('N', 'NW', 'NE', 'S', 'SE', 'SW', 'W', 'E')) ); CREATE TABLE Orders (Order# NUMBER(4), Customer# NUMBER(4), OrderDate DATE NOT NULL, ShipDate DATE, ShipStreet VARCHAR2(18), ShipCity VARCHAR2(15), ShipState VARCHAR2(2), ShipZip VARCHAR2(5), ShipCost NUMBER(4,2), CONSTRAINT orders_order#_pk PRIMARY KEY(order#), CONSTRAINT orders_customer#_fk FOREIGN KEY (customer#) REFERENCES customers(customer#)); In...
Perform SQL queries in the given data structure. write an SQL query that gives the number...
Perform SQL queries in the given data structure. write an SQL query that gives the number of courses taken for every student in the student table. For each instructor, show the instructor name and the number of sections that have been taught by that instructor. You do not need to include instructors who have never taught a section. List in order of decreasing the number of sections taught. Give the number of semester/year combinations in which sections have been offered....
This is my code but I am having trouble with the SECTION and REGISTRATION table. The...
This is my code but I am having trouble with the SECTION and REGISTRATION table. The error for section says course id isn't a column and with registration, it says there are no foreign key but that is all that is in the registration table. CREATE TABLE STUDENT(StudentID integer, StudentName char(25) NOT NULL, primary key(StudentName)) CREATE TABLE FACULTY(FacultyID integer, FacultyName char(25) NOT NULL, primary key(FacultyID)) CREATE TABLE COURSE(CourseID integer, CourseName char(15) NOT NULL, primary key(CourseID)) CREATE TABLE QUALIFIED(DateQualified date, FacultyID...
-- Table construction (just 1 simplest possible way) CREATE TABLE PetType ( petTypeId VARCHAR(10) PRIMARY KEY,...
-- Table construction (just 1 simplest possible way) CREATE TABLE PetType ( petTypeId VARCHAR(10) PRIMARY KEY, animalType VARCHAR(20), breed VARCHAR(20) ); CREATE TABLE Owner ( ownerId VARCHAR(10) PRIMARY KEY, firstName VARCHAR(20), lastName VARCHAR(20) NOT NULL, homePhoneNumber VARCHAR(20), streetAddress VARCHAR(80), suburb VARCHAR(20), postcode VARCHAR(10) ); CREATE TABLE Pet ( petId VARCHAR(10) PRIMARY KEY, petName VARCHAR(20), sex CHAR(1) CHECK (sex IN ('M', 'F')), petTypeId VARCHAR(10) FOREIGN KEY REFERENCES PetType ); CREATE TABLE PetAndOwner ( ownerId VARCHAR(10), petId VARCHAR(10), PRIMARY KEY (ownerId, petId),...
This is my code, but when I try to create my "Qualified" Table it won't let...
This is my code, but when I try to create my "Qualified" Table it won't let me enter foreign keys and I don't know why. CREATE TABLE STUDENT(StudentID integer, StudentName char(25) NOT NULL, primary key(StudentName)) CREATE TABLE FACULTY(FacultyID integer, FacultyName char(25) NOT NULL, primary key(FacultyID)) CREATE TABLE COURSE(CourseID integer, CourseName char(15) NOT NULL, primary key(CourseID)) CREATE TABLE QUALIFIED(DateQualified date, foreign key(FacultyID) references FACULTY(FacultyID), foreign key(CourseID) references COURSE(CourseID))
Write the SQL statements for creating a table Event with primary key e_id, and an event...
Write the SQL statements for creating a table Event with primary key e_id, and an event date, e_date that cannot be null. Also write the statements to create a table Participant with primary key p_id, a name that can be up to 30 characters long but may be shorter, and an event e_id as a foreign key that references the corresponding event.
Create 2 stored procedures: sp_AddNewUser and sp_AddNewRole. Use the ManyToMany script as your base table structures....
Create 2 stored procedures: sp_AddNewUser and sp_AddNewRole. Use the ManyToMany script as your base table structures. The stored procedure should accept the parameters needed to input the data for each table. NOTE: You do not need to input the UserID or RoleID. These are surrogate keys and the system automatically inserts them when you insert a row in the tables.   On execution, the stored procedure should check the database to see if the user exists, if so, return a message...
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...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment 4’s schema (Customer-Invoice-Line-Product-Vendor). Make sure that your SQL script runs without any errors. Submit your answers in a .SQL file. 1 (2 Points) - Find the count of distinctvendors thatsupplied products that are priced lowerthan 185? 2 (2 Points) - For each vendor, find their product that has the lowest product quantity. Your output should include vendor code, vendor name, product description and product...
For each account of the previous question, compute the Balance, and return a table that shows...
For each account of the previous question, compute the Balance, and return a table that shows the account number, type, and balance for each account (hint: use UNION). The list of customer names that have transactions greater than or equal to one thousand dollars. A) Answer this question using only nested queries (i.e., each select is over only one table). B) Answer this query using joins. Bank.sql is under this statement. DROP DATABASE IF EXISTS Bank; CREATE DATABASE Bank; USE...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT