0% found this document useful (0 votes)
37 views3 pages

CSU 07314 Practical #3 - 2023 SQL

The document describes tasks and queries related to creating and querying databases for a bank account and dog breeding application. It includes creating tables, adding sample data using inserts, and writing queries to retrieve and aggregate data from the tables.

Uploaded by

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

CSU 07314 Practical #3 - 2023 SQL

The document describes tasks and queries related to creating and querying databases for a bank account and dog breeding application. It includes creating tables, adding sample data using inserts, and writing queries to retrieve and aggregate data from the tables.

Uploaded by

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

THE INSTITUTE OF FINANCE MANAGEMENT

COMPUTER SCIENCE AND MATHS DEPARTMENT

BCS/ BIT
[ YEAR 2]

CSU/ ITU 07314. DBMS -2023/2024


Practical#3 __SQL, (Due 20-24 Nov-2023)
Instructor: Siphy, A.S;
____________________________________________________
Task_1 BANK_ACCOUNT DB
-----------------------------------------------------------------------------------
T1Q1.
-- Create a table to describe a bank Account (BankAccount_tbl), providing:
------>the account number(Aid) (must be 12 digits long). This is the primary key.
------>the account holder's name (AcName)(can be up to 50 characters, must be
present)
------>the account type(AcType) (must hold the value 'D' for deposit, or 'C' for current)
-----> the date the account was opened(OpenDate) (this can default to the date
that the row is added).
-----> the current balance in the account(AcBalance), up to a maximum of
9,999,999,999.99.
-- //On creating the account, the default balance is 500,0000 and balance should
not be less that 100,000.//
T1Q2.
---------------------------------------------------------------------------------
-- Create a table to describe a Transaction_tbl, providing:
-----> a transaction number(TIN) (a 7-digit number that is the primary key)
------> the account number(Account) to which the transaction applies. //FK -apply
delete cascade//
------>this account must exist in the transaction table.
------->the date and time of the transaction named as TransDate
it should be able to record date and time when transanction has been
committed.
set default SYSDATE/current_date.
-------> the Transaction Type (TransType)(this can hold a value 'D' for deposit, or 'W'
for withdrawal).
-------->the Transaction Amount(TransAmount) (up to 9,999,999,999.99)
----------------------------------------------------------------------------------
T1Q3.
-- > Alter the account table to add a phone number.
//It can be up to 12 digits long and may be left as null.//
T1Q4.
-->Represent the following information using INSERTS ONLY in the appropriate
tables:
-- Paul Hunt (phone no: 08765543322) is opening a current account
-- number 123456789012 right now, with no money in it.
-- He deposits 3000 euro in transaction 1 now.
-- He withdraws 2500 euro in transaction 2 now.
-- John Smith (phone no: 0622000001) is opening a deposit account
-- number 123456788011 right now, with 20,000 as first deposit.
-- He withdraws 2000 euro in transaction 2 now.
*****//Add 8 more rows by yourselves in each table*****//

QUERIES :Write SQL queries to do the following;


--------------------------------------------------------------------------------
Q1) Display all bank account numbers, types and their current balances
Q2) Display every bank account's no, transaction type and its date conducted.
Q3) Display all bank account details which have no transanction yet
Q4) Dispay every bank account's no, transanction's number, date and time of
transaction,
and the number of transanctions for that account.
Q5) List every account's number, transaction's number and count of transanctions
for that account
Q6) List all bank accounts which have more that one transation.
Include sum of the transanction amounts.

TASK 2: BREED_DOG DB
---------------------------------------------------------------------------------
CREATE TABLE Breed_tbl
(
BreedId CHAR(7) NOT NULL PRIMARY KEY ,
SpecialNeeds VARCHAR2(20) NULL ,
TypicalSize INTEGER NOT NULL ,
BreedName VARCHAR2(30) NOT NULL);
---------------------------------------------------------------------------------
CREATE TABLE Dog_tbl
(
DogTag CHAR(6) NOT NULL PRIMARY KEY ,
BreedId CHAR(7) REFERENCES BREED ON DELETE CASCADE,
Nature varchar2(50) NULL ,
COSTPRICE number(7,2),
dogName VARCHAR2(20) NOT NULL,
DoBirth DATE NOT NULL);
--------------------------------------------------------------------------------
Use inserts only command to add the following details
*******************************************************************
Insert into Breed_tbl
values ('GLDRTVR','Regular exercise',110,'Golden Retriever');
Insert into Breed_tbl
values ('CHUAHWA','Warm environment',30,'Chihuahua');
Insert into Breed_tbl
values ('BLABRDR','Human company',130,'Black Labrador');
Insert into Breed_tbl
values ('DLMTION','Space to roam',150,'Dalmation');
Insert into Breed_tbl
values ('RTWEILR','Keep away from kids',500,'Rotweiller');
*********************************************************************
Insert into Dog_tbl
values ('K33A44','BLABRDR','Friendly, Playful',150.00,'Sooty',SYSDATE-365);
Insert into Dog_tbl
values ('K33A65','BLABRDR','Happy, Peaceful, friendly',100,'Pal',SYSDATE-730);
Insert into Dog_tbl
values ('K55A43','CHUAHWA','Excitable, Yappy',250.00,'Pooch', SYSDATE-100);
Insert into Dog_tbl
values ('K33A55','GLDRTVR','Calming, Peaceful', 180,'Goldy',SYSDATE-500);
Insert into Dog_tbl
values ('K44A55','CHUAHWA','Nervous, Irritable',50,'Patch',SYSDATE-544);
Insert into Dog_tbl
values ('K44A33','CHUAHWA','Bright-eyed, Lively',150,'Tiny',SYSDATE-50);
********************************************************************
T2Q5
For every dog, return the words 'The dog called ', followed by the dog's name,
followed by ' is a ', followed by the breed name, ending with a full stop.
-- example row: The dog Goldy is a Golden Retriever.

T2Q6.Display each dog's tag, name and age in years.


T2Q7.Display the breedId and breed name of all breeds for which we have no dogs.

T2Q8.Display each breed name and the number and value of dogs for that breed.
--Sample output: Chihuahua 3 450.00
T2Q9.Display the dog tag, name, breed and costprice of all dogs
who cost more than the average costprice.
----------------------------------------------------------------------------------

You might also like