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

Dbms 123

The document describes an insurance database with tables for people, cars, accidents, car ownership, and accident participation. It provides the structure to create the tables, insert sample data, and demonstrates how to update data and find counts by joining tables and filtering on dates and models. The database can be used to generate reports and build a front-end interface for querying and displaying query results.

Uploaded by

vtestv30
Copyright
© Attribution Non-Commercial (BY-NC)
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)
117 views3 pages

Dbms 123

The document describes an insurance database with tables for people, cars, accidents, car ownership, and accident participation. It provides the structure to create the tables, insert sample data, and demonstrates how to update data and find counts by joining tables and filtering on dates and models. The database can be used to generate reports and build a front-end interface for querying and displaying query results.

Uploaded by

vtestv30
Copyright
© Attribution Non-Commercial (BY-NC)
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

1. Consider the Insurance database given below.

The primary keys are underlined and the data types are specified: PERSON (driver id #: String, name: string, address: string) CAR (regno: string, model: string, year: int) ACCIDENT (report-number: int, accd-date: date, location: string) OWNS (driver-id #:string, Regno:string) PARTICIPATED (driver-id: string, Regno:string, report-number:int, damage amount:int) (i) Create the above tables by properly specifying the primary keys and the foreign keys. create table person ( driver_id varchar(10) primary key, name varchar(10), address varchar(20) ); create table car ( regno varchar(12) primary key, model varchar(10), year number(4) ); create table accident ( repno number(3) primary key, accd_date date, location varchar(12) ); create table owns ( driver_id varchar(10) references person(driver_id), regno varchar(12) references car(regno), primary key(driver_id,regno) ); create table participated ( driver_id varchar(10) references person(driver_id), regno varchar(12) references car(regno), repno number(3) references accident(repno), damage_amt number(10,2), primary key(driver_id,regno,repno) ); Enter at least five tuples for each relation. insert into person values ('dr1','salman','bapunagar, bombay'); insert into person values ('dr2','diganth','rrnagar, bangalore');

(ii)

insert into person values ('dr3','vijay','goripalya, mysore'); insert into person values ('dr4','darshan','gubbi, mandya'); insert into person values ('dr5','sudeep','jaynagar, bangalore'); insert into car values ('dl01-h1234','innova','2008'); insert into car values ('ka01-m1234','santro','2007'); insert into car values ('ka09-s1234','maruthi','2005'); insert into car values ('ka11-f1234','innova','2008'); insert into car values ('ka01-h1234','innova','2006'); insert into accident values (3,'01-jan-2008','delhi'); insert into accident values (6,'01-jun-2007','bangalore'); insert into accident values (9,'01-nov-2007','tumkur'); insert into accident values (12,'01-sep-2008','bangalore'); insert into accident values (15,'01-apr-2006','bangalore'); insert into owns values ('dr1','dl01-h1234'); insert into owns values ('dr2','ka01-m1234'); insert into owns values ('dr3','ka09-s1234'); insert into owns values ('dr4','ka11-f1234'); insert into owns values ('dr5','ka01-h1234'); insert into participated values ('dr1','dl01-h1234',3,704245); insert into participated values ('dr2','ka01-m1234',6,35653); insert into participated values ('dr3','ka09-s1234',9,54323); insert into participated values ('dr4','ka11-f1234',12,17439); insert into participated values ('dr5','ka01-h1234',15,42174);

(iii) Demonstrate how you a. Update the damage amount to 25000 for the car with a specific Regno in the ACCIDENT table with report number 12. update participated set damage_amt=25000 where repno=12;

b. Add a new accident to the database. insert into accident values (18,'01-mar-2008','bangalore');

(iii)

Find the total number of people who owned cars that were involved in accidents in 2008. select count(*) as cnt_acc from accident,participated,person where ( (participated.repno=accident.repno) and (participated.driver_id=person.driver_id) and (accident.accd_date like '%08') );

(iv)

Find the number of accidents in which cars belonging to a specific model were involved. select count(*) as cnt from car where model='innova';

(vi) Generate suitable reports. (vii) Create suitable front end for querying and displaying the results.

You might also like