0% found this document useful (0 votes)
3 views4 pages

Create Table Personaniket

The document outlines the creation of several database tables related to a vehicle accident management system, including tables for persons, cars, accidents, ownership, and participation in accidents. It includes SQL commands for inserting data into these tables, querying the data, and updating records. Additionally, it provides examples of how to count distinct drivers and total cars based on specific criteria.

Uploaded by

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

Create Table Personaniket

The document outlines the creation of several database tables related to a vehicle accident management system, including tables for persons, cars, accidents, ownership, and participation in accidents. It includes SQL commands for inserting data into these tables, querying the data, and updating records. Additionally, it provides examples of how to count distinct drivers and total cars based on specific criteria.

Uploaded by

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

create table person(driver_id varchar(10),name varchar(10),address varchar(10),primary key(driver_id));

create table car(regno varchar(10),model varchar(10),year int,primary key(regno));

create table accident(report_number int,accd_date date,location varchar(10),primary


key(report_number));

create table owns(driver_id varchar(10),regno varchar(10),primary key(driver_id,regno),foreign


key(driver_id) references person(driver_id),foreign key(regno) references car(regno));

create table participated(driver_id varchar(10),regno varchar(10),report_number int,damage_amount


int,primary key(driver_id,regno,report_number),foreign key(driver_id) references
person(driver_id),foreign key(regno) references car(regno),foreign key(report_number) references
accident(report_number));

desc person

desc car

desc participated

desc owns

desc accident

insert into person values('01','Aniket','Delhi');

insert into person values('02','shiv','Mumbai');

insert into person values('03','Sahil','Janak Puri');

insert into person values('04','Nishant','Goa');


select * from person;

insert into car values('11','Mercedez',2030);

insert into car values('22','BMW',2025);

insert into car values('333','Lambhorgni',2002);

insert into car values('44','Audi',20001);

select * from car;

insert into accident values(111,'25-May-2020','Delhi');

insert into accident values(222,'26-June-2019','Pune');

insert into accident values(333,'027-April-2041','Mumbai');

insert into accident values(444,'28-March-2012','Delhi');

select * from accident;

insert into owns values('1','123');

insert into owns values('2','234');


insert into owns values('3','345');

insert into owns values('4','456');

select * from owns;

insert into participated values('01','11',111,800);

insert into participated values('02','22',222,3000);

insert into participated values('03','33',333,3500);

insert into participated values('04','44',444,4000);

select * from participated;

update participated set damage_amount=50000 where report_number=222 and regno='234';

select * from participated;

insert into accident values(500,'10-August-2122','Noida');

select * from accident;


select count(distinct o.driver_id) as People from owns o,participated p,accident a where a.accd_date
like

'%22' and o.regno=p.regno and p.report_number=a.report_number;

select count(*) as Totalcars from car c,participated p where c.regno=p.regno and c.model='santro';

You might also like