Question

Task1: Construct and run the code for a natural inner join on the two tables

                        AccountState and AccountUserState

Task 2: Construct and run the code for a natural inner join of

                        AccountState, AccountUserState, ClientProperty

Task 3: Construct and run the code for Right outer join on ClientProperty and

                                    AccountUserState

Task 4: Construct and run the code to sum the account totals for each branch.

Construct your own database for this and enter the data.

AccountNr, BranchNr, ClientNr PlaceCode, are all Int. MoneyAmout is Decimal with 7 digits total with 2 digits to the right of the decimal. CityName and ClientName are Varchar(15)

Client ClientName inr has Account N is for is usedMy code for the tables and the above DML commands

/*A12.6DB assignment and also used for final quiz

*

* Author: rob r

* Created: Nov 27, 2016

* An extension of Fig 12.22 plus another branch from the

* branch office, see A12.6DBAssignment.doc in IFT 200 folder

*/

drop table AccountState;

drop table AccountUserState;

drop table BranchProperty;

drop table ClientProperty;

create table AccountState(

branchNr Int not null,

accountNr Int not null,

balance Decimal(7,2) not null

);

insert into AccountState values

(10, 54, 3000.00),

(10, 77, 500.55),

(23, 88, 2000.00),

(23, 54, 1000.00);

create table AccountUserState(

branchNr Int not null,

accountNr Int not null,

clientNr Int not null

);

insert into AccountUserState values

(10, 54,1001),

(10, 54,1002),

(10, 77,2013),

(23, 54,7654);

create table BranchProperty(

branchNr Int not null Primary Key,

placeCode Int not null,

cityName Varchar(15)not null

);

insert into BranchProperty values

(10, 228, 'Heber'),

(23, 357, 'Cornville'),

(15, 210, 'HorseGulch');

create table ClientProperty(

clientNr Int not null Primary Key,

clientName Varchar(15) not null

);

insert into CLientProperty values(1001 , 'Jones, ME'),

(1002, 'Jones,TA'),

(2013, 'Jones,TA'),

(7654, 'Seldon, H'),

(8005, 'Shankara, TA');

--select *

--from AccountState natural join AccountUserState;

select *

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Task 1: select * from AccountState as inner join AccountUserState aus on as.branchNr = aus.branchNr

Task 2: select * from AccountState as inner join AccountUserState aus on as.branchNr = aus.branchNr inner join ClientProperty cp on cp.clientNr = aus.clientNr

Task 3: select * from AccountUserState aus right outer ClientProperty cp on cp.clientNr = aus.clientNr

                                    AccountUserState

Add a comment
Know the answer?
Add Answer to:
Task1: Construct and run the code for a natural inner join on the two tables                        ...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using Oracle database Need help getting the JAVA code for the queries and the rest of...

    Using Oracle database Need help getting the JAVA code for the queries and the rest of the instructions. Need the table provided converted and fulfil  the requirements. . For this project - you will be writing a program (you may choose whatever programming language you want) to read in your database tables from Lab 5, and then print out the contents of each of the tables. Additionally, you must print at least one query each with the following clauses: *JOIN (any...

  • WRITE SQL QUERY THAT DOES THE FOLLOWING Q3| Find the customer's name and branch names of...

    WRITE SQL QUERY THAT DOES THE FOLLOWING Q3| Find the customer's name and branch names of all customers who do have accounts but not a loan in the bank. And find those customers who do have loan but not have an account in the bank. GIVEN DATABASE TABLES 2 Account table Branch table Customer table Loan table BNAME 3 A# CNAME BNAME BAL BNAME ASSETS BCITY CNAME STREET CCITY CNAME AMT 1234 Baba 2222 Rahimi Sauthdale Ridgedale 150eee Minnetonka Minnetonka...

  • Database Management 6. [5] Create the following table: CREATE TABLE customer ( cust_name VARCHAR(30) NOT NULL,...

    Database Management 6. [5] Create the following table: CREATE TABLE customer ( cust_name VARCHAR(30) NOT NULL, address VARCHAR(60), UNIQUE (cust name, address)); A. Run the following inserts and explain why both work and how will you prevent it INSERT INTO customer VALUES ('Alex Doe', NULL); INSERT INTO customer VALUES ('Alex Doe', NULL); 7. [5] Modify the following table definition to ensure that all employees have a minimum wage of $10 CREATE TABLE employee ( empId INT PRIMARY KEY, empName VARCHAR(40)...

  • Use the SQL statements provided to create your tables. Write one SQL statement for each of...

    Use the SQL statements provided to create your tables. Write one SQL statement for each of the following problems. You can only use the conditions listed in the tasks. E.g., in task 1, you cannot manually look up pid of Information Systems undergraduate program. Here is the given code: drop table textbook_schedule cascade constraints; drop table textbook_author cascade constraints; drop table schedule cascade constraints; drop table course cascade constraints; drop table textbook cascade constraints; drop table author cascade constraints; drop...

  • a database of employees that corresponds to the employee-payroll hierarchy is provided (see employees.sql to create...

    a database of employees that corresponds to the employee-payroll hierarchy is provided (see employees.sql to create the employees for a MySQL database). Write an application that allows the user to: Add employees to the employee table. Add payroll information to the appropriate table for each new employee. For example, for a salaried employee add the payroll information to the salariedEmployees table 1 is the entity-relationship diagram for the employees database Figure 1: Table relationships in the employees database [1]. Add...

  • Create SQL statements based on the given tables: Code to create the tables: CREATE DATABASE LAB...

    Create SQL statements based on the given tables: Code to create the tables: CREATE DATABASE LAB4DB; USE LAB4DB; CREATE TABLE CUSTOMER ( CUS_CODE int primary key, CUS_LNAME varchar(15), CUS_FNAME varchar(15), CUS_INITIAL varchar(1), CUS_AREACODE varchar(3), CUS_PHONE varchar(8), CUS_BALANCE float(8) ); INSERT INTO CUSTOMER VALUES('10010','Ramas','Alfred','A','615','844-2573','0'); INSERT INTO CUSTOMER VALUES('10011','Dunne','Leona','K','713','894-1238','0'); INSERT INTO CUSTOMER VALUES('10012','Smith','Kathy','W','615','894-2285','345.86'); INSERT INTO CUSTOMER VALUES('10013','Olowski','Paul','F','615','894-2180','536.75'); INSERT INTO CUSTOMER VALUES('10014','Orlando','Myron','','615','222-1672','0'); INSERT INTO CUSTOMER VALUES('10015','O''Brian','Amy','B','713','442-3381','0'); INSERT INTO CUSTOMER VALUES('10016','Brown','James','G','615','297-1228','221.19'); INSERT INTO CUSTOMER VALUES('10017','Williams','George','','615','290-2556','768.93'); INSERT INTO CUSTOMER VALUES('10018','Farriss','Anne','G','713','382-7185','216.55'); INSERT INTO CUSTOMER VALUES('10019','Smith','Olette','K','615','297-3809','0'); /*...

  • need help fixing this code. also need a screenshot of it running thank you /* Creating...

    need help fixing this code. also need a screenshot of it running thank you /* Creating table. */ CREATE TABLE HOM(story_name varchar (255), [user] char(50), age int, reading_counts int NOT NULL, CONSTRAINT Story_User PRIMARY KEY (story_name,[user])); INSERT INTO HOM VALUES ('Humpty Dumpty', 'Andrea', 5, 10); INSERT INTO HOM VALUES ('Wheels on the Bus', 'Simon', 3, 15); INSERT INTO HOM VALUES ('Baa Baa Black Sheep', 'Leo', 7, 4); INSERT INTO HOM VALUES ('Jack and Jill', 'James', 4, 11); INSERT INTO HOM...

  • Using the code below in Oracle SQL Live I keep getting an error message for the...

    Using the code below in Oracle SQL Live I keep getting an error message for the last 4 INSERTS. The error message is: ORA-00932: inconsistent datatypes: expected DATE got NUMBER. How do I correct that error? CREATE TABLE BASE ( BASENUM CHARACTER(3) NOT NULL, BASECITY varchar(20), BASESTATE CHARACTER(2), BASEPHON varchar(10), BASEMGR varchar(10), PRIMARY KEY (BASENUM) ); CREATE TABLE TYPE ( TYPENUM CHARACTER(1) NOT NULL, TYPEDESC varchar(30), PRIMARY KEY (TYPENUM) ); CREATE TABLE TRUCK ( TNUM CHARACTER(4) NOT NULL, BASENUM CHARACTER(3),...

  • Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and...

    Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and phones of all swimmers currently in level (of id) 3. +-------+---------+---------------------------+ | FName | LName   | EMail                     | +-------+---------+---------------------------+ | Bobby | Khan    | theBKhan1 | | Clara | Johnson | ClaraJohnson_11 | +-------+---------+---------------------------+ 2 rows in set (0.00 sec) (2) Provide the names of swimmers who have signed up to participate in the event '100M Butterfly' of Meet id 1. +-------+---------+ | FName...

  • I need help with the following SQL query for a company database (script given below). The...

    I need help with the following SQL query for a company database (script given below). The name of the Department. The number of employees working in that department. The number of different projects controlled by this department. The name of the project controlled by this department that has the maximum number of employees of the company working on it. The number of the above project. The cumulative sum of the number of employees of the company working on the projects...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT