You are on page 1of 13

DATABASE MANAGEMENT FOR

LOSS ASSESSMENT SYSTEM


1] Consider the insurance data base given below. The primary key 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 ,date , location : string )
OWNS(driver-id# : string , Regno : string)
PARTICIPATED(driver-id# : string , Regno : string, report-number : int ,damage amount : int)

1. Create the above tables by properly specifying the primary keys and the foreign keys.
2. Enter at least five tuples for each relation .
3. Demonstrate how you
a) update the damage amount for the car with a specific Regno in the accident with report number 12 to
25000. b) add a new accident to the database.
4. Find the total number of people who owned cars that were involved in accidents in 2002
5. Find the number of accident in which cars belonging to a specific model were involved.
6. Generation of suitable reports.
7.Create suitable front end for querying and displaying the results.
1. Create the above tables by properly specifying the primary keys and the foreign keys.

• Create table person(driverid varchar(10), name varchar(10), address varchar(10), primary


key(driverid );
• Create table car(regno varchar(10), model varchar(10), year int, primary key (regno));
• Create table accident( reportno int, Accdate date , location varchar(10), primary key (reportno));
• Create table owns(driverid varchar(10),regno varchar(10), primary key(driverid),foreign
key(driverid) references person (driverid), foreign key(regno) reference car(regno));
• Create table participated(driverid varchar(10) ,regno varchar(10),reportno int, dmgamt int, primary
key(driverid), foreign key(driverid) references person( driverid), foreign key(regno) references
car(regno),foreign key(reportno) references accident(reportno));
2. Enter at least five tuples for each relation.

1. Create table person(driverid varchar(10), name varchar(10), address varchar(10), primary


key(driverid ); insert into person values(‘1000’, ‘Akash’, ‘Hasan’); insert into person values(‘1001’,
‘Ramesh’, ‘Hubli’); insert into person values(‘1002’, ‘Preeti’, ‘Gadag’); insert into person
values(‘1003’, ‘Rahul’, ‘Bangalore’); insert into person values(‘1004’, ‘Rohan’, ‘Mandya’);
select * from person ; +----------+--------
+----------+
|driverid | name | address |
+----------+--------+----------+
|1000 | Akash | Hasan |
|1001 | Ramesh| Hasan |
|1002 | Preeti | Hasan | |
1003 | Rahul | Hasan | |
1004 | Rohan | Hasan |
+----------+--------+----------+
2. Create table car(regno varchar(10), model varchar(10), year int, primary key (regno));
insert into car values(‘MA25’ ,
’SANTRO’ ,2000); insert into car
values(‘KA26’ , ’INDIGO’ ,2012); insert into
car values(‘TM20’ , ’I10’ ,2011); insert into
car values(‘AP25’ , ’I20’ ,2012); insert into car
values(‘KA25’ , ’INDICA’ ,2013);
select * from car ;
+----------+-------------+-------+
|regno | model | year |
+----------+-------------+---- ---+
| MA25 | SANTRO| 2000 | |
KA26 | INDIGO | 2012 |
| TM20 | I10 | 2011 |
| AP25 | I20 | 2012 |
| KA25 | INDICA | 2013 |
+----------+-------------+-------+
3. Create table accident( reportno int, Accdate date , location varchar(10), primary key (reportno));

insert into accident values(200, ‘2012/01/03’, ‘Mg Road’);


insert into accident values(201, ‘2012/12/04’, ‘PB Road’);
insert into accident values(202, ‘2013/03/30’, ‘ST Road’);
insert into accident values(203, ‘2010/04/23’, ‘MGM
Road’); insert into accident values(204, ‘2012/09/13’, ‘SB
Road’);

select * from accident ;


+-------------+----------------+-------------+
|reportno | accident | location |
+-------------+----------------+-------------+
|200 | 2012/01/03 | Mg Road |
|201 | 2012/12/04 | PB Road |
|202 |‘2013/03/30 | ST Road |
|203 | 2010/04/23 | MGM Road |
|204 | 2012/09/13 | SB Road |
+-------------+----------------+-------------+
4. Create table owns(driverid varchar(10),regno varchar(10), primary key(driverid),foreign key(driverid)
references person (driverid), foreign key(regno) reference car(regno));

insert into owns values(‘1000’, ’ MA25’);


insert into owns values(‘1001’, ’ KA26’);
insert into owns values(‘1002’, ’ TM20’);
insert into owns values(‘1003’, ’ AP25’);
insert into owns values(‘1004’, ’ KA25’);
select * from owns ;
+------------+---------+
| driverid | regno |
+------------+---------+
| 1000 | MA25 |
| 1001 | KA25 |
| 1002 | TM25 |
| 1003 | AP25 |
| 1004 | KA25 |
+------------+---------+
5. Create table participated(driverid varchar(10) ,regno varchar(10),reportno int, dmgamt int, primary
key(driverid), foreign key(driverid) references person( driverid), foreign key(regno) references
car(regno),foreign key(reportno) references accident(reportno));
insert into participated values(‘1000’, ’ MA25’, 200, 2000);
insert into participated values(‘1001’, ’ KA26’, 201, 4000);
insert into participated values(‘1002’, ’ TM20’, 202, 6000);
insert into participated values(‘1003’, ’ AP25’, 203, 8000);
insert into participated values(‘1004’, ’ KA25’, 204,
10000); select * from participated ;
+----------+---------+-----------+------------+
| driverid | regno | reportno | dmgamt |
+----------+---------+-----------+------------+
| 1000 | MA25 | 200 | 2000 |
| 1001 | KA26 | 201 | 4000 | | 1002
| TM20 | 202 | 6000 |
| 1003 | AP25 | 203 | 8000 |
| 1004 | KA25 | 204 | 10000 |
+----------+---------+-----------+------------+
3. Demonstrate how you
a) update the damage amount for the car with a specific Regno in the accident with report number 12 to
25000. b) add a new accident to the database.

a) update the damage amount for the car with a specific Regno in the accident with report number 12 to 25000.
update participated
set dmgamt=25000
where regno=‘MA25’ and reportno=200 ;
Rows matched :1 changed: 1 warnings: 0
select * from participated ;
+----------+---------+-----------+------------+
| driverid | regno | reportno | dmgamt |
+----------+---------+-----------+------------+
| 1000 | MA25 | 200 | 25000 |
| 1001 | KA26 | 201 | 4000 | | 1002
| TM20 | 202 | 6000 |
| 1003 | AP25 | 203 | 8000 |
| 1004 | KA25 | 204 | 10000 |
+----------+---------+-----------+------------+
b) add a new accident to the database.

insert into accident values(205, ‘2012/09/05’, ‘KB Road’);

select * from accident ;


+-------------+----------------+-------------+
|reportno | accident | location |
+-------------+----------------+-------------+
|200 | 2012/01/03 | Mg Road |
|201 | 2012/12/04 | PB Road |
|202 |‘2013/03/30 | ST Road |
|203 | 2010/04/23 | MGM Road |
|204 | 2012/09/13 | SB Road |
|205 | 2012/09/05 | KB Road |
+-------------+----------------+-------------+
4. Find the total number of people who owned cars that were involved in accidents in 2002 select
count(*)
from accident a, participated p
where a. reportno= p.reportno and Accdate BETWEEN ‘2012/01/01’ AND ‘2012/12/30’;
+-------------+
| count(*) |
+-------------+
| 3 |
+-------------+
5. Find the number of accident in which cars belonging to a specific model were involved.
select count(*) from car
c, participated p
where c.regno =p.regno and model=‘Indica’;
+-------------+
| count(*) |
+-------------+
| 1 |
+-------------+
E - R DIAGRAM

Driver - id Address Name Regno Model Year

MERSON OWNS CAR


Report - number location Date

PARTITICIPATED ACCIDENT

Damage amount

You might also like