CSU 07314 Practical #3 - 2023 SQL
CSU 07314 Practical #3 - 2023 SQL
BCS/ BIT
[ YEAR 2]
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.
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.
----------------------------------------------------------------------------------