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
how would the data insert MYSQL query for below table look like: CREATE TABLE Appointments( AppointmentID...
how would the data insert MYSQL query for below table look like: CREATE TABLE Appointments( AppointmentID int NOT NULL, Date Time datetime, Details varchar(100), Remarks varchar(200), POwnerID int, TenantID int, SerAgtID int, PRIMARY KEY (AppointmentID), FOREIGN KEY (POwnerID) REFERENCES Property Owners (POwnerID), FOREIGN KEY (TenantID) REFERENCES Tenants (TenantID), FOREIGN KEY (SerAgtID) REFERENCES Service Agents (SerAgtID));
-- 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),...
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...
Create table Student (       ssn numeric primary key,       name char(50),       address varchar(100),       major  char(10)
Create table Student (       ssn numeric primary key,       name char(50),       address varchar(100),       major  char(10) ); create view CS_Student as             select ssn, name, address from student where major = 'CS'; create a trigger on this view. If a tuple is inserted into the view, then insert it into the base table. If a tuple is deleted from the view, then delete it from the base table.
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...
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...
Assignment Instructions (MY WORK IN MYSQLBENCH)- Follow instructions in class to download and build a database...
Assignment Instructions (MY WORK IN MYSQLBENCH)- Follow instructions in class to download and build a database in your DBMS. Write and demonstrate queries (in-class) that do the following: Download the appropriate attached SQL file for your DBMS. Load the file into your database design tool and run it to build the Pine Valley Furniture Company database. This is the database that is used in the textbook examples for both Chapters 5 and 6. Write a query to show the price...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT