You are on page 1of 27

DBMS PROJECT

INSURANCE MANAGEMENT SYSTEM COMPANY


By Ghazal Shambayati
NEU ID:001238014

Contents
 PROBLEM STATEMENT

 DATABASES IMPLEMENTED WITH ER MODEL

 SQL QUERIES

PROBLEM STATEMENT

The project is focused on Insurance Management System, which shows information about
different parts of insurance company, such as Agent, Customer, Policy, Employee, Claim
Handling and other related concepts, such as Claim, Premium, and different kinds of Insurance
policies.
The objective of the project here, is to implement a database management system, such that, it
uses the different tables to evaluate the performance of Insurance company.

Using this database can help insurance companies in order to answer some questions such as:
 How many customers they already have?
 How many policies they have?
 How many customers have more than one policy?
 Which kind of policy sold the highest?
 How much is the premium that the company got from customer?
 How many policies have been claimed?
 Recognize customers that have more policies.
 Recognize customers that have more valuable policies.
 Calculate high/low risk customers.
 Calculate best policies, which cost more premium and have less claim, and also number
of policy sold that includes those factors.
 Calculate average time to recompense for damage.

DATABASES IMPLEMENTED WITH ER MODEL


SQL QUERIES
Store Procedures:

DELIMITER //
CREATE procedure ClaimCustomer( IN claim int(20),OUT customer_name varchar(20) )
Begin
set customer_name =(select concat(first_name,' ',last_name) from person
where Person_Id = (
select person_id from Customer
where Customer_ID = (
select customer_id from policy
where Policy_ID = (
select Policy_ID from Claim
where Claim_ID = claim))));
END; //

DELIMITER ;

call ClaimCustomer(217217,@v);
select @v;

Triggers:

CREATE TABLE IF NOT EXISTS `insurance_management`.`policy_log` (


`Policy_ID` INT(11) NOT NULL,
`Agent_ID` int(30) NOT NULL,
`Customer_ID` int(30) NOT NULL,
`Premium_ID` int(30) NOT NULL,
`Date` date NOT NULL)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

DELIMITER //
CREATE DEFINER = CURRENT_USER TRIGGER
`insurance_management`.`policy_BEFORE_UPDATE` BEFORE UPDATE ON `policy` FOR
EACH ROW
BEGIN
insert into policy_log
set policy_id = old.policy_id,
agent_id = old.agent_id,
customer_id = old.customer_id,
premium_id = old.premium_id,
date = now();

END;//

DELIMITER ;

drop trigger policy_BEFORE_UPDATE

select * from policy

select * from policy_log


select * from customer;
View

CREATE DATABASE IF NOT EXISTS `insurance_management` /*!40100 DEFAULT


CHARACTER SET latin1 */;
USE `insurance_management`;
-- MySQL dump 10.13 Distrib 5.7.12, for osx10.9 (x86_64)
--
-- Host: 127.0.0.1 Database: insurance_management
-- ------------------------------------------------------
-- Server version 5.7.15

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT


*/;
/*!40101 SET
@OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION
*/;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS,
UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,
FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE,
SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `Address`
--

DROP TABLE IF EXISTS `Address`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Address` (
`Address_ID` int(11) NOT NULL,
`Country` varchar(30) NOT NULL,
`City` varchar(30) NOT NULL,
`Street` varchar(30) NOT NULL,
`Zip` varchar(10) NOT NULL,
PRIMARY KEY (`Address_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `Address`
--

LOCK TABLES `Address` WRITE;


/*!40000 ALTER TABLE `Address` DISABLE KEYS */;
INSERT INTO `Address` VALUES (1,'Valiasr Ave','Tehran','1969633391','Iran'),(2,'Shahid
Haghani Express Way','Tehran','1969633392','Iran'),(3,'Farmington
Avenue\r','Hartford','6105','USA'),(4,'Aarlington Rd','Akron','44312','USA'),(5,'Race
St','Philadelphia','19107','USA'),(6,'Clinton','Cambridge','2139','USA'),(7,'Commenwealth','Br
ighton','2135','USA'),(8,'Vanak','Tehran','7887','Iran'),(9,'Seyed
Khandan','Tehran','7997','Iran'),(10,'Clinton','Cambridge','2139','USA'),(11,'ChinaTown','Bost
on','2140','USA'),(12,'33','NewYork','2345','USA'),(13,'42','Maryland','2090','USA'),(14,'Amo
re','Paris','56789','France'),(15,'Chal','Dehli','8980','India'),(16,'Secrete
23','Doshanbe','908746','Pakistan'),(17,'Chaharbagh','Isfahan','1472','Iran'),(18,'Ferdosy','Mas
hhad','9020','Iran'),(19,'Fatemi','Tehran','7881','Iran'),(20,'Ozgol','Tehran','12390','Iran'),(21,'K
arimkhan','Shiraz','89345','Iran'),(22,'Pole
khajoo','Isfahan','53859','Iran'),(23,'Hantingtone','Boston','21459','USA'),(24,'Valiasr
Ave','Tehran','78493','Iran'),(25,'42','NewYork','6793','USA'),(26,'1','NewYork','8932','USA'),
(27,'Ararat','Tehran','74689','Iran'),(28,'Kalhor','Kashan','3498233','Iran'),(29,'Sheikhbahaei','T
ehran','12543','Iran'),(30,'Takejoubi','Tehran','34508','Iran'),(31,'Deilaman','Tehran','23985','Ir
an'),(32,'Leily','Tehran','87569','Iran'),(33,'Nirooentezami','Tehran','789456','Iran'),(34,'45','Ch
igaco','23456','USA'),(35,'22','Maryland','56692','USA'),(36,'Braintree','Boston','2145','USA'),
(37,'Alewife','Boston','2149','USA'),(38,'Warren','Boston','213450','USA'),(39,'Kenedy','Dalla
s','7834','USA'),(40,'Clinton','Dallas','6783','USA'),(41,'Ashmont','Boston','2190','USA'),(42,'3
4','Akron','56689','USA'),(43,'12','NewYork','5612','USA'),(44,'Heily','Vancouver','12903','Ca
nada'),(45,'Ruggles','Boston','68646','USA'),(46,'Seol','Montreal','58906','Canada'),(47,'Tehra
n','Losangles','60763','USA'),(48,'Bisotoon','Isfahan','97654','Iran'),(49,'Ashmont','Boston','21
568','USA'),(50,'Aftab','Tehran','897654','Iran'),(51,'25','NewYork','452198','USA'),(52,'6','Ne
wYork','685488','USA'),(53,'Iranzamin','Tehran','8790854','Iran'),(54,'masoomeh','Kashan','70
9895','Iran'),(55,'Shoosh','Tehran','38720','Iran'),(56,'Pamenar','Tehran','2989756','Iran'),(57,'P
oonak','Tehran','897590','Iran'),(58,'Saadat_Abad','Tehran','8790290','Iran'),(59,'Foresthill','Bo
ston','2167','USA'),(60,'Elm','Boston','2198','USA'),(61,'Tabrizi','Tehran','970230','Iran'),(62,'6
9','NewYork','6790','USA'),(63,'21','NewYork','2690','USA'),(64,'Allameh','Tehran','586982','
Iran'),(65,'Enghelab','Kashan','32239','Iran'),(66,'87','Philadelphia','21702','USA'),(67,'Azadi','
Tehran','21828','Iran'),(68,'Naghsh_e_Jahan','Isfahan','21768','Iran'),(69,'Bahar','Tehran','3246
7','Iran');
/*!40000 ALTER TABLE `Address` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `Agent`
--

DROP TABLE IF EXISTS `Agent`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Agent` (
`Agent ID` int(11) NOT NULL,
`Address_ID` int(20) NOT NULL,
`Insurance_ID` int(20) NOT NULL,
`Person_ID` int(11) NOT NULL,
PRIMARY KEY (`Agent ID`),
KEY `FK_Followed_By_idx` (`Insurance_ID`),
KEY `FK_Located_At_idx` (`Address_ID`),
KEY `FK_person_idx` (`Person_ID`),
CONSTRAINT `FK_Followed_By_1` FOREIGN KEY (`Insurance_ID`) REFERENCES
`Insurance_Company` (`Insurance ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_Located_At` FOREIGN KEY (`Address_ID`) REFERENCES
`Address` (`Address_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `FK_person` FOREIGN KEY (`Person_ID`) REFERENCES `Person`
(`Person_Id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `Agent`
--

LOCK TABLES `Agent` WRITE;


/*!40000 ALTER TABLE `Agent` DISABLE KEYS */;
INSERT INTO `Agent` VALUES
(123,1,111000,17),(456,1,222000,18),(789,1,333000,19),(1122,2,444000,20),(1455,2,555000
,21),(1788,3,666000,22),(2121,3,777000,23),(2454,3,888000,24),(2787,3,999000,25),(3120,
4,1110000,26),(3453,4,1221000,27),(3786,4,1332000,28),(4119,4,1443000,29),(4452,5,1554
000,30),(4785,5,1665000,31),(5118,5,1776000,32);
/*!40000 ALTER TABLE `Agent` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `Agent_Customer`
--

DROP TABLE IF EXISTS `Agent_Customer`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Agent_Customer` (
`Agent ID` int(20) NOT NULL,
`Customer ID` int(20) NOT NULL,
KEY `FK_Customer_Join_idx` (`Customer ID`),
KEY `FK_Agent_Join_idx` (`Agent ID`),
CONSTRAINT `FK_Agent_Join` FOREIGN KEY (`Agent ID`) REFERENCES `Agent`
(`Agent ID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `FK_Customer_Join` FOREIGN KEY (`Customer ID`) REFERENCES
`Customer` (`Customer_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `Agent_Customer`
--

LOCK TABLES `Agent_Customer` WRITE;


/*!40000 ALTER TABLE `Agent_Customer` DISABLE KEYS */;
INSERT INTO `Agent_Customer` VALUES
(123,12345),(456,23456),(789,34567),(1122,45678),(1455,56789),(1788,67900),(2121,7901
1),(2454,90122),(2787,101233),(3120,112344),(3453,123455),(3786,134566),(4119,145677)
,(4452,156788),(4785,167899),(5118,179010),(123,190121),(456,201232),(789,212343),(14
55,223454),(1122,234565),(4452,245676),(5118,267898);
/*!40000 ALTER TABLE `Agent_Customer` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `Claim`
--

DROP TABLE IF EXISTS `Claim`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Claim` (
`Claim_ID` int(20) NOT NULL,
`Date` date NOT NULL,
`Amount` float NOT NULL,
`Paid` enum('Y','N') NOT NULL,
`Policy_ID` int(20) NOT NULL,
PRIMARY KEY (`Claim_ID`),
KEY `Policy_ID_idx` (`Policy_ID`),
CONSTRAINT `Policy_ID` FOREIGN KEY (`Policy_ID`) REFERENCES `Policy`
(`Policy_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `Claim`
--

LOCK TABLES `Claim` WRITE;


/*!40000 ALTER TABLE `Claim` DISABLE KEYS */;
INSERT INTO `Claim` VALUES (135,'2016-01-02',100.07,'Y',1010),(7911,'2016-04-
07',143.06,'Y',2020),(15687,'2016-09-08',220.45,'N',3030),(23463,'2016-02-
05',136.87,'Y',4040),(31239,'2016-04-02',567.98,'Y',5050),(39015,'2016-09-
04',86.55,'Y',6060),(46791,'2016-02-02',49.79,'N',7070),(54567,'2016-07-
05',98.33,'N',8080),(62343,'2016-09-08',691.68,'Y',9090),(70119,'2016-02-
05',276.99,'Y',10100),(77895,'2016-02-05',200,'N',11110),(85671,'2016-04-
02',338.98,'Y',12120),(93447,'2016-01-03',278,'N',13130),(101223,'2016-05-
05',69.45,'N',14140),(108999,'2016-03-06',985.44,'Y',15150),(116775,'2016-02-
08',825.34,'Y',16160),(124551,'2016-05-12',156.68,'Y',17170),(132327,'2016-02-
05',333.96,'Y',18180),(140103,'2016-01-02',242.76,'Y',19190),(147879,'2016-04-
07',129.32,'Y',20200),(155655,'2016-05-11',96.67,'Y',21210),(163431,'2016-03-
06',285.85,'Y',22220),(171207,'2016-02-08',359.73,'N',23230),(178983,'2016-04-
04',100.67,'N',24240),(217217,'2016-05-09',200.68,'N',1010);
/*!40000 ALTER TABLE `Claim` ENABLE KEYS */;
UNLOCK TABLES;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode =
'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZER
O_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGI
NE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 Trigger
not_paid_claim
before
insert on claim
for each row
begin

if new.paid = 'N' then


insert into Claim_not_paid
set
Claim_ID = new.Claim_ID,
amount = new.Amount;
end if;
End */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;

--
-- Table structure for table `Claim_not_paid`
--

DROP TABLE IF EXISTS `Claim_not_paid`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Claim_not_paid` (
`Claim_ID` int(11) NOT NULL,
`Amount` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Claim_not_paid`
--

LOCK TABLES `Claim_not_paid` WRITE;


/*!40000 ALTER TABLE `Claim_not_paid` DISABLE KEYS */;
/*!40000 ALTER TABLE `Claim_not_paid` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `Customer`
--

DROP TABLE IF EXISTS `Customer`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Customer` (
`Customer_ID` int(11) NOT NULL,
`SSN` varchar(45) NOT NULL,
`Date` date NOT NULL,
`Addres_ID` int(20) NOT NULL,
`Person_ID` int(11) NOT NULL,
PRIMARY KEY (`Customer_ID`),
UNIQUE KEY `Customer_ID_UNIQUE` (`Customer_ID`),
KEY `FK_Located_At_idx` (`Addres_ID`),
KEY `FK_customer_idx` (`Person_ID`),
CONSTRAINT `FK_Located_At_1` FOREIGN KEY (`Addres_ID`) REFERENCES
`Address` (`Address_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_customer` FOREIGN KEY (`Person_ID`) REFERENCES `Person`
(`Person_Id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `Customer`
--

LOCK TABLES `Customer` WRITE;


/*!40000 ALTER TABLE `Customer` DISABLE KEYS */;
INSERT INTO `Customer` VALUES (12345,'123456789','1993-07-
04',6,33),(23456,'987654321','1993-04-07',7,34),(34567,'851851853','1993-01-
09',8,35),(45678,'271604938','1997-10-13',9,36),(56789,'358024691','1992-07-
17',10,37),(67900,'449444444','1992-04-20',11,38),(79011,'530864198','1992-01-
23',12,39),(90122,'612839513','1991-10-27',13,40),(101233,'707037045','1981-07-
31',14,41),(112344,'790123457','1991-05-04',15,42),(123455,'876432109','1991-02-
05',16,43),(134566,'962629641','1990-11-09',17,44),(145677,'149387173','1996-08-
13',18,45),(156788,'115804705','1989-05-17',19,46),(167899,'122222237','1990-02-
18',20,47),(179010,'108649769','1989-11-22',21,48),(190121,'130617301','1978-08-
26',22,49),(201232,'148181833','1989-05-30',23,50),(212343,'156901365','1989-03-
03',24,51),(223454,'154320987','1979-12-05',25,52),(234565,'174070749','1988-09-
08',26,53),(245676,'182760461','1988-06-12',27,54),(256787,'191358293','1988-03-
16',28,55),(267898,'200000025','1987-12-19',29,56);
/*!40000 ALTER TABLE `Customer` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `Employee`
--

DROP TABLE IF EXISTS `Employee`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Employee` (
`Employee_ID` int(20) NOT NULL,
`Office_ID` int(20) NOT NULL,
`Person_ID` int(11) NOT NULL,
PRIMARY KEY (`Employee_ID`),
UNIQUE KEY `Employee_ID_UNIQUE` (`Employee_ID`),
KEY `FK_Has_idx` (`Office_ID`),
KEY `FK_employee_idx` (`Person_ID`),
CONSTRAINT `FK_Has_1` FOREIGN KEY (`Office_ID`) REFERENCES `Office`
(`Office_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_employee` FOREIGN KEY (`Person_ID`) REFERENCES `Person`
(`Person_Id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `Employee`
--

LOCK TABLES `Employee` WRITE;


/*!40000 ALTER TABLE `Employee` DISABLE KEYS */;
INSERT INTO `Employee` VALUES
(180,1234,1),(190,5678,2),(200,10122,3),(210,14566,4),(220,19010,5),(230,23454,6),(240,2
7898,7),(250,32342,8),(260,36786,9),(270,41230,10),(280,45674,11),(290,50118,12),(300,54
562,13),(310,59006,14),(320,63450,15),(330,67894,16);
/*!40000 ALTER TABLE `Employee` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `Health_Policy`
--

DROP TABLE IF EXISTS `Health_Policy`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Health_Policy` (
`Policy_ID` int(20) NOT NULL,
PRIMARY KEY (`Policy_ID`),
KEY `FK_ISA_idx` (`Policy_ID`),
CONSTRAINT `FK_ISA_3` FOREIGN KEY (`Policy_ID`) REFERENCES `Policy`
(`Policy_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `Health_Policy`
--

LOCK TABLES `Health_Policy` WRITE;


/*!40000 ALTER TABLE `Health_Policy` DISABLE KEYS */;
/*!40000 ALTER TABLE `Health_Policy` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `Policy_Type`
--

DROP TABLE IF EXISTS `Policy_Type`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Policy_Type` (
`Policy_Type_Code` int(11) NOT NULL,
`Type` varchar(75) NOT NULL,
PRIMARY KEY (`Policy_Type_Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `Policy_Type`
--

LOCK TABLES `Policy_Type` WRITE;


/*!40000 ALTER TABLE `Policy_Type` DISABLE KEYS */;
INSERT INTO `Policy_Type` VALUES (1111,'Vehicle'),(2222,'Home'),(3333,'Health');
/*!40000 ALTER TABLE `Policy_Type` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Premium`
--

DROP TABLE IF EXISTS `Premium`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Premium` (
`Premium_ID` int(20) NOT NULL,
`Amount` float NOT NULL,
`Date` date NOT NULL,
`Paid` enum('Y','N') NOT NULL,
PRIMARY KEY (`Premium_ID`,`Date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `Premium`
--

LOCK TABLES `Premium` WRITE;


/*!40000 ALTER TABLE `Premium` DISABLE KEYS */;
INSERT INTO `Premium` VALUES (132,100,'2016-07-16','Y'),(243,324.5,'2016-09-
16','Y'),(354,100,'2016-10-16','N'),(465,278.68,'2016-12-16','Y'),(576,120,'2016-09-
16','Y'),(687,290,'2016-02-16','Y'),(798,100,'2016-02-16','N'),(909,129,'2016-07-
16','N'),(1020,120,'2016-03-16','Y'),(1131,290.7,'2016-01-16','Y'),(1242,178.8,'2016-01-
16','N'),(1353,100,'2016-08-16','Y'),(1464,324.5,'2016-09-16','N'),(1575,218,'2016-04-
16','N'),(1686,100,'2016-09-16','Y'),(1797,100,'2016-07-16','Y'),(1908,236,'2016-01-
16','Y'),(2019,100,'2016-01-16','Y'),(2130,236.87,'2016-01-16','Y'),(2241,259,'2016-05-
16','Y'),(2352,324.5,'2016-01-16','Y'),(2463,120,'2016-02-16','Y'),(2574,100,'2016-05-
16','N'),(2685,120,'2016-07-16','N'),(2796,124.78,'2016-08-16','Y'),(2907,324.5,'2016-05-
16','Y'),(3018,240.67,'2016-09-16','Y'),(3129,88.89,'2016-07-16','Y'),(3240,324.5,'2016-01-
16','Y'),(3351,239.46,'2016-01-16','Y'),(3462,100,'2016-01-16','N'),(3573,324.5,'2016-02-
16','N'),(3684,89.7,'2016-05-16','Y'),(3795,98,'2016-01-16','Y'),(3906,93.64,'2016-04-
16','Y'),(4017,100,'2016-02-16','N');
/*!40000 ALTER TABLE `Premium` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `Report`
--

DROP TABLE IF EXISTS `Report`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Report` (
`Report_ID` int(20) NOT NULL,
`Policy_ID` int(20) NOT NULL,
`Date` date NOT NULL,
`Report_Comment` varchar(45) DEFAULT NULL,
PRIMARY KEY (`Report_ID`),
KEY `FK_Folloed_By_idx` (`Policy_ID`),
CONSTRAINT `FK_Followed_By_2` FOREIGN KEY (`Policy_ID`) REFERENCES
`Policy` (`Policy_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `Report`
--

LOCK TABLES `Report` WRITE;


/*!40000 ALTER TABLE `Report` DISABLE KEYS */;
/*!40000 ALTER TABLE `Report` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `Vehicle_Policy`
--

DROP TABLE IF EXISTS `Vehicle_Policy`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Vehicle_Policy` (
`Vehicle_Type_ID` int(20) NOT NULL,
`Policy_ID` int(20) NOT NULL,
`Color` varchar(30) DEFAULT NULL,
`Number` int(11) NOT NULL,
`Model` varchar(45) DEFAULT NULL,
PRIMARY KEY (`Policy_ID`),
KEY `FK_ISA_idx` (`Policy_ID`),
KEY `FK_Has_7` (`Vehicle_Type_ID`),
CONSTRAINT `FK_Has_7` FOREIGN KEY (`Vehicle_Type_ID`) REFERENCES
`Vehicle_Type` (`Vehicle_Type_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_ISA` FOREIGN KEY (`Policy_ID`) REFERENCES `Policy`
(`Policy_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `Vehicle_Policy`
--

LOCK TABLES `Vehicle_Policy` WRITE;


/*!40000 ALTER TABLE `Vehicle_Policy` DISABLE KEYS */;
INSERT INTO `Vehicle_Policy` VALUES
(101010,1010,'Black',11713,'2016'),(101010,2020,'Black',67234,'2016'),(101010,3030,'Red',1
2435,'2010'),(202020,4040,'Blue',89932,'2011'),(202020,5050,'White',89689,'2011'),(303030,
6060,'Black',68096,'2012'),(101010,7070,'Blue',68893,'2011'),(303030,8080,'White',98904,'2
014'),(101010,9090,'Gray',89732,'1999'),(303030,10100,'Red',89763,'2000'),(303030,11110,'
White',34902,'2002');
/*!40000 ALTER TABLE `Vehicle_Policy` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `Vehicle_Type`
--

DROP TABLE IF EXISTS `Vehicle_Type`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Vehicle_Type` (
`Vehicle_Type_ID` int(20) NOT NULL,
`Type` varchar(45) NOT NULL,
PRIMARY KEY (`Vehicle_Type_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `Vehicle_Type`
--

LOCK TABLES `Vehicle_Type` WRITE;


/*!40000 ALTER TABLE `Vehicle_Type` DISABLE KEYS */;
INSERT INTO `Vehicle_Type` VALUES
(101010,'Car'),(202020,'Truck'),(303030,'Motorcycle');
/*!40000 ALTER TABLE `Vehicle_Type` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Temporary view structure for view `agent_details`
--

DROP TABLE IF EXISTS `agent_details`;


/*!50001 DROP VIEW IF EXISTS `agent_details`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `agent_details` AS SELECT
1 AS `Agent ID`,
1 AS `first_name`,
1 AS `last_name`,
1 AS `Policy_ID`,
1 AS `Customer_ID`,
1 AS `customer_first_name`,
1 AS `customer_last_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `claim_handling`
--

DROP TABLE IF EXISTS `claim_handling`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `claim_handling` (
`Agent_ID` int(20) NOT NULL,
`Name` varchar(75) NOT NULL,
`Email` varchar(100) DEFAULT NULL,
`phone_number` varchar(20) DEFAULT NULL,
`Address_ID` int(20) DEFAULT NULL,
`Claim_ID` int(20) NOT NULL,
PRIMARY KEY (`Claim_ID`),
KEY `FK_Has_idx` (`Agent_ID`),
KEY `FK_Located_At_idx` (`Address_ID`),
KEY `FK_Pays_For_idx` (`Claim_ID`),
CONSTRAINT `FK_Has` FOREIGN KEY (`Agent_ID`) REFERENCES `Agent` (`Agent
ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_Located_At_3` FOREIGN KEY (`Address_ID`) REFERENCES
`Address` (`Address_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_Pays_For` FOREIGN KEY (`Claim_ID`) REFERENCES `Claim`
(`Claim_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `claim_handling`
--

LOCK TABLES `claim_handling` WRITE;


/*!40000 ALTER TABLE `claim_handling` DISABLE KEYS */;
INSERT INTO `claim_handling` VALUES
(123,'Parsian','Claim@parsianinsurance.com','9878921826',45,135),(456,'Mellat','claim@mel
at.ir','9821085333',46,7911),(789,'Aetna','claim@Aetna.com','1808723862',47,15687),(1122,'
AIU','claim@AIU.com','1330456338',48,23463),(1455,'Americhoice','claim@Americhoice.c
om','1282384210',49,31239),(1788,'Parsian','Claim@parsianinsurance.com','9820827346',50,
39015),(2121,'Aetna','claim@Aetna.com','1800923882',51,46791),(2454,'AIU','claim@AIU.c
om','1530455308',52,54567),(2787,'Parsian','Claim@parsianinsurance.com','9878331827',53,
62343),(3120,'Mellat','claim@melat.ir','9882085334',54,70119),(3453,'Aetna','claim@Aetna.
com','1617893982',55,77895),(3786,'Parsian','Claim@parsianinsurance.com','98239227829',
56,85671),(4119,'Americhoice','claim@Americhoice.com','12152484380',57,93447),(4452,'
Aetna','claim@Aetna.com','18578723964',58,101223),(4785,'Americhoice','claim@Americh
oice.com','13423984223',59,108999),(5118,'Parsian','Claim@parsianinsurance.com','9834592
3826',60,116775),(456,'Mellat','claim@melat.ir','98217985333',61,124551),(2787,'Parsian','C
laim@parsianinsurance.com','98596431827',62,132327),(2454,'AIU','claim@AIU.com','1530
4455308',63,140103),(1122,'AIU','claim@AIU.com','13306456338',64,147879),(4452,'Aetna
','claim@Aetna.com','18578723964',65,155655),(123,'Parsian','Claim@parsianinsurance.com
','98458621826',66,163431),(2787,'Parsian','Claim@parsianinsurance.com','98456031827',67
,171207),(123,'Parsian','Claim@parsianinsurance.com','98542921826',68,178983);
/*!40000 ALTER TABLE `claim_handling` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `home_policy`
--

DROP TABLE IF EXISTS `home_policy`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `home_policy` (
`Policy_ID` int(20) NOT NULL,
`Address_ID` int(20) NOT NULL,
`home_cost` float(8,2) DEFAULT NULL,
`year_of_built` date DEFAULT NULL,
PRIMARY KEY (`Policy_ID`),
KEY `Address_ID_idx` (`Address_ID`),
CONSTRAINT `FK_ISA_2` FOREIGN KEY (`Policy_ID`) REFERENCES `Policy`
(`Policy_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_Located_At_7` FOREIGN KEY (`Address_ID`) REFERENCES
`Address` (`Address_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `home_policy`
--

LOCK TABLES `home_policy` WRITE;


/*!40000 ALTER TABLE `home_policy` DISABLE KEYS */;
INSERT INTO `home_policy` VALUES (12120,58,50000.00,'1905-06-
02'),(13130,59,27345.98,'1905-05-28'),(14140,60,29345.37,'1905-04-
03'),(15150,61,87327.89,'1905-04-30'),(16160,62,64345.34,'1905-06-
22'),(17170,63,12345.98,'1905-04-11'),(18180,64,24345.00,'1905-06-
23'),(19190,65,45345.99,'1905-06-15'),(20200,66,67345.80,'1905-06-
11'),(21210,67,15345.00,'1905-06-14'),(22220,68,27389.50,'1905-05-
31'),(23230,69,25645.45,'1905-03-13');
/*!40000 ALTER TABLE `home_policy` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `insurance_Company`
--

DROP TABLE IF EXISTS `insurance_Company`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `insurance_Company` (
`Insurance ID` int(20) NOT NULL,
`Name` varchar(75) NOT NULL,
`Email` varchar(100) DEFAULT NULL,
`phone_number` varchar(20) DEFAULT NULL,
PRIMARY KEY (`Insurance ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `insurance_Company`
--

LOCK TABLES `insurance_Company` WRITE;


/*!40000 ALTER TABLE `insurance_Company` DISABLE KEYS */;
INSERT INTO `insurance_Company` VALUES
(111000,'Parsian','info@parsianinsurance.com','Phone
number'),(222000,'Parsian','info@parsianinsurance.com','0098-
21825'),(333000,'Parsian','info@parsianinsurance.com','0098-
21825'),(444000,'Mellat','info@melat.ir','0098-
21825'),(555000,'Mellat','info@melat.ir','0098-
2185333'),(666000,'Aetna','info@Aetna.com','0098-
2185333'),(777000,'Aetna','info@Aetna.com','001-800-872-
3862'),(888000,'Aetna','info@Aetna.com','001-800-872-
3862'),(999000,'Aetna','info@Aetna.com','001-800-872-
3862'),(1110000,'AIU','info@AIU.com','001-800-872-
3862'),(1221000,'AIU','info@AIU.com','001-330-645-
6338'),(1332000,'AIU','info@AIU.com','001-330-645-
6338'),(1443000,'AIU','info@AIU.com','001-330-645-
6338'),(1554000,'Americhoice','info@Americhoice.com','001-330-645-
6338'),(1665000,'Americhoice','info@Americhoice.com','001-215-238-
4210'),(1776000,'Americhoice','info@Americhoice.com','001-215-238-4210');
/*!40000 ALTER TABLE `insurance_Company` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `office`
--

DROP TABLE IF EXISTS `office`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `office` (
`Office_ID` int(20) NOT NULL,
`Agent_ID` int(20) NOT NULL,
`Address_ID` int(20) NOT NULL,
PRIMARY KEY (`Office_ID`),
KEY `FK_Located_At_idx` (`Address_ID`),
KEY `FK_Followed_By_idx` (`Agent_ID`),
CONSTRAINT `FK_Located_At_4` FOREIGN KEY (`Address_ID`) REFERENCES
`Address` (`Address_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_followed_by_4` FOREIGN KEY (`Agent_ID`) REFERENCES `Agent`
(`Agent ID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `office`
--

LOCK TABLES `office` WRITE;


/*!40000 ALTER TABLE `office` DISABLE KEYS */;
INSERT INTO `office` VALUES
(1234,123,29),(5678,456,30),(10122,789,31),(14566,1122,32),(19010,1455,33),(23454,1788,
34),(27898,2121,35),(32342,2454,36),(36786,2787,37),(41230,3120,38),(45674,3453,39),(50
118,3786,40),(54562,4119,41),(59006,4452,42),(63450,4785,43),(67894,5118,44);
/*!40000 ALTER TABLE `office` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `person`
--

DROP TABLE IF EXISTS `person`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `person` (
`first_name` varchar(20) DEFAULT NULL,
`Last_Name` varchar(45) NOT NULL,
`Person_Id` int(11) NOT NULL,
`Gender` enum('M','F') NOT NULL,
`Email` varchar(45) NOT NULL,
`phone_number` varchar(20) DEFAULT NULL,
PRIMARY KEY (`Person_Id`),
UNIQUE KEY `Person_Id_UNIQUE` (`Person_Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `person`
--

LOCK TABLES `person` WRITE;


/*!40000 ALTER TABLE `person` DISABLE KEYS */;
INSERT INTO `person` VALUES
('Reza','Shambayati',1,'M','Reza.shambayati@gmail.com','7812064832'),('Donya','Labaf',2,'F'
,'donya2323@yahoo.com','7898064532'),('Yusuf','Ozbec',3,'M','y.ozbec@yahoo.com','78912
39832'),('Kal','Bugrara',4,'M','kal_bugrara@gmail.com','7899864532'),('Hasan','Rohani',5,'M',
'rohani1393@yahoo.com','7822664987'),('Farzane','Besharatian',6,'F','fbeshar@gmail.com','8
576664532'),('Mohammad','Ketabi',7,'M','mamadk@yahoo.com','1209664532'),('Paria','Ghan
adian',8,'F','pariaG@gmail.com','7896664530'),('Mahsa','Zeinali',9,'F','m_zeinali@yahoo.com
','7896612345'),('Shahab','Hosseini',10,'M','shahab_hosseini@gmail.com','2396666632'),('Zar
i','Makan',11,'F','zm45@yahoo.com','7856663512'),('Hamidreza','Lesani',12,'M','hlesani@gm
ail.com','7896645132'),('Mandana','Soori',13,'F','soorym@gmail.com','7896663333'),('Soosan
','Yakhchali',14,'F','susy123@gmail.com','9036664532'),('Sarah','Pooli',15,'F','Sarah.g@gmail
.com','7896954531'),('Sarah','Gorg',16,'F','Sarahg@husky.neu.edu','7896664532'),('Amol
','Mohammadi',17,'F','info@parsianinsuranceA.com','0098-21826'),('Ilam
','Ahmadi',18,'M','info@parsianinsuranceB.com','0098-21827'),('Babol
','Rezaei',19,'M','info@parsianinsuranceC.com','0098-21828'),('Tehran
','Asgharnejad',20,'F','info@melat1.ir','0098-2185334'),('Isfahan
','Akbari',21,'F','info@melat2.ir','0098-2185335'),('Pratik
','Patre',22,'M','info@Aetnaa.com','001-800-872-
3863'),('Ghazal','Badbakht',23,'F','info@Aetnab.com','001-800-872-
3864'),('Karan','nemidoonam',24,'F','info@Aetnac.com','001-800-872-
3865'),('Rahol','nem',25,'M','info@Aetnad.com','001-800-872-
3866'),('May','Avril',26,'F','info@AIU1.com','001-330-645-6339'),('Ahmad
','Saghari',27,'M','info@AIU2.com','001-330-645-
6336'),('Laleh','Zhian',28,'M','info@AIU3.com','001-330-645-
6333'),('Janatan','Raeesi',29,'M','info@AIU4.com','001-330-645-6332'),('Soroush
','Kamrava',30,'F','info@AmerichoiceA.com','001-215-238-4213'),('Kamran
','Ebrahimi',31,'F','info@AmerichoiceB.com','001-215-238-
4214'),('Saina','Sheini',32,'M','info@AmerichoiceC.com','001-215-238-
4215'),('Ghazaal','Shambayati',33,'F','ghazal.shambayati@gmail.com','8579995899'),('Farah','
Besharatian',34,'F','FarahBesharatian@gmail.com','9126090407'),('Mehrnoosh','Samaki',35,'F
','Mehrnoosh.Samaki@gmail.com','6176690223'),('Emad','Zebhi',36,'M','Emad_Zebhi@gmail
.com','9123724242'),('Barzin','Hakimi',37,'M','Barzin.Hakimi@gmail.com','9122145508'),('B
ahare','Hakimi',38,'F','Bahare_Hakimi@yahoo.com','9836728378'),('Amirali','Shambayati',39,
'M','Amirali.shambayati@gmail.com','203-870-
2491'),('Mehdi','Modabber',40,'M','mehdi_modabberchelsea@yahoo.com','8372647482'),('M
ohammadreza','Khani',41,'M','mohammadreza.khxni@gmail.com','8372927283'),('Samaneh','
Kazemi',42,'F','samane.kazemi@gmail.com','8464735372'),('May','Altayeb',43,'F','may_altay
ebamin@yahoo.com','631-393-
0706'),('Julia','Gomez',44,'F','julia.gomez@husky.neu.edu','7779812989'),('Robert','Virgle',45
,'M','robertv@hotmail.com','718-975-
1179'),('Yahya','Besharatian',46,'F','yahyabeshar@gmail.com','888-276-
5255'),('Aida','Shirazi',47,'F','aidapixel@yahoo.com','855-267-
8468'),('Bita','Golpayegani',48,'F','batoulG@yahoo.com','1-888-225-
5322'),('Negisa','Mirzaei',49,'F','negnegm@yahoo.com','1-844-432-
2275'),('Shima','Samsami',50,'F','shimas@gmail.com','1-866-418-
0232'),('Majid','Hashemi',51,'F','majid.minahashemi@gmail.com','202-357-
5900'),('Prooria','Rashidi',52,'M','pooriar@hotmail.com','202-357-
5900'),('Hope','Armstrong',53,'M','hopearmstrong@yahoo.com','617-635-
5348'),('Daniel','Sharifikia',54,'M','danielkia@gmail.com','617-635-
1195'),('Mahsa','Bayati',55,'F','mahsabayati@gmail.com','91272040'),('Kiarash','Naimian',56,'
M','knaimian@yahoo.com','9124184672');
/*!40000 ALTER TABLE `person` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `policy`
--

DROP TABLE IF EXISTS `policy`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `policy` (
`Policy_ID` int(20) NOT NULL,
`Issue_Date` date NOT NULL,
`End_Date` date NOT NULL,
`Policy_Type_ID` int(20) NOT NULL,
`Agent_ID` int(20) NOT NULL,
`Customer_ID` int(20) NOT NULL,
`Premium_ID` int(20) NOT NULL,
PRIMARY KEY
(`Policy_ID`,`Customer_ID`,`Policy_Type_ID`,`Issue_Date`,`End_Date`),
KEY `FK_Followed_By_idx` (`Policy_Type_ID`),
KEY `FK_Followed_By_idx1` (`Agent_ID`),
KEY `FK_Handles_By_idx` (`Customer_ID`),
KEY `FK_Has_idx` (`Premium_ID`),
CONSTRAINT `FK_Followed_By_6` FOREIGN KEY (`Policy_Type_ID`)
REFERENCES `Policy_Type` (`Policy_Type_Code`) ON DELETE CASCADE ON
UPDATE CASCADE,
CONSTRAINT `FK_Handles_By` FOREIGN KEY (`Customer_ID`) REFERENCES
`Customer` (`Customer_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_Has_2` FOREIGN KEY (`Premium_ID`) REFERENCES `Premium`
(`Premium_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_followed_by_5` FOREIGN KEY (`Agent_ID`) REFERENCES `Agent`
(`Agent ID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `policy`
--

LOCK TABLES `policy` WRITE;


/*!40000 ALTER TABLE `policy` DISABLE KEYS */;
INSERT INTO `policy` VALUES (1010,'2014-01-01','2018-05-
04',1111,123,12345,132),(2020,'4014-03-02','2019-03-07',2222,456,12345,243),(3030,'2015-
04-04','2020-06-03',3333,789,34567,354),(4040,'2015-05-07','2020-09-
04',1111,1122,45678,465),(5050,'2015-08-06','2019-03-
03',1111,1455,56789,576),(6060,'2015-05-23','2020-04-
06',1111,1788,67900,687),(7070,'4014-03-02','2018-01-
01',2222,2121,79011,798),(8080,'2015-04-04','2021-07-
02',1111,2454,90122,909),(9090,'2015-05-07','2018-09-
09',2222,2787,101233,1020),(10100,'2012-03-14','2019-06-
23',3333,3120,112344,1131),(11110,'2014-05-08','2018-01-
24',3333,3453,123455,1242),(12120,'2012-02-04','2021-08-
29',2222,3786,134566,1353),(13130,'2013-02-06','2018-05-
04',1111,4119,145677,1464),(14140,'2013-07-02','2018-03-
07',1111,4452,156788,1575),(15150,'2014-01-03','2020-06-
14',2222,4785,167899,1686),(16160,'2015-05-06','2019-03-
07',3333,5118,179010,1797),(17170,'4014-03-02','2020-06-
03',2222,1788,190121,1908),(18180,'2015-04-04','2020-09-
04',2222,2121,201232,2019),(19190,'2014-05-08','2019-01-
30',1111,2454,212343,2130),(20200,'2012-02-01','2018-01-
01',2222,2787,223454,2241),(21210,'2013-02-06','2021-07-
04',1111,3120,234565,2352),(22220,'4014-03-09','2019-06-
25',2222,3453,245676,2463),(23230,'2015-04-04','2020-07-
02',3333,3786,256787,2574),(24240,'2015-05-07','2018-04-07',3333,4119,267898,2685);
/*!40000 ALTER TABLE `policy` ENABLE KEYS */;
UNLOCK TABLES;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode =
'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZER
O_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGI
NE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER
`insurance_management`.`policy_BEFORE_UPDATE` BEFORE UPDATE ON `policy`
FOR EACH ROW
BEGIN
insert into policy_log
set policy_id = old.policy_id,
agent_id = old.agent_id,
customer_id = old.customer_id,
premium_id = old.premium_id,
date = now();

END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;

--
-- Table structure for table `policy_log`
--

DROP TABLE IF EXISTS `policy_log`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `policy_log` (
`Policy_ID` int(11) NOT NULL,
`Agent_ID` int(30) NOT NULL,
`Customer_ID` int(30) NOT NULL,
`Premium_ID` int(30) NOT NULL,
`Date` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `policy_log`
--

LOCK TABLES `policy_log` WRITE;


/*!40000 ALTER TABLE `policy_log` DISABLE KEYS */;
INSERT INTO `policy_log` VALUES (2020,456,23456,243,'2016-12-10');
/*!40000 ALTER TABLE `policy_log` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `report_log`
--

DROP TABLE IF EXISTS `report_log`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `report_log` (
`Report_ID` int(10) NOT NULL,
`Policy_ID` int(11) NOT NULL,
`Date` date NOT NULL,
`Report_Comment` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `report_log`
--

LOCK TABLES `report_log` WRITE;


/*!40000 ALTER TABLE `report_log` DISABLE KEYS */;
/*!40000 ALTER TABLE `report_log` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Dumping events for database 'insurance_management'
--

--
-- Dumping routines for database 'insurance_management'
--
/*!50003 DROP PROCEDURE IF EXISTS `CalculatePremium` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode =
'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZER
O_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGI
NE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CalculatePremium`( IN agent
varchar(20),OUT premium Float )
Begin
set premium =(select sum(pre.amount)
from policy po,premium pre
where po.premium_id = pre.premium_id
and po.agent_id = agent
group by po.agent_id
order by agent_id);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ClaimCustomer` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode =
'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZER
O_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGI
NE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ClaimCustomer`( IN claim
int(20),OUT customer_name varchar(20) )
Begin
set customer_name =(select concat(first_name,' ',last_name) from person
where Person_Id = (
select person_id from Customer
where Customer_ID = (
select customer_id from policy
where Policy_ID = (
select Policy_ID from Claim
where Claim_ID = claim))));
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;

--
-- Final view structure for view `agent_details`
--

/*!50001 DROP VIEW IF EXISTS `agent_details`*/;


/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
/*!50001 SET character_set_client = utf8 */;
/*!50001 SET character_set_results = utf8 */;
/*!50001 SET collation_connection = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `agent_details` AS select `a`.`Agent ID` AS `Agent ID`,`p`.`first_name` AS
`first_name`,`p`.`Last_Name` AS `last_name`,`po`.`Policy_ID` AS
`Policy_ID`,`c`.`Customer_ID` AS `Customer_ID`,`d`.`first_name` AS
`customer_first_name`,`d`.`Last_Name` AS `customer_last_name` from ((((`agent` `a` join
`person` `p` on((`a`.`Person_ID` = `p`.`Person_Id`))) left join `policy` `po`
on((`po`.`Agent_ID` = `a`.`Agent ID`))) left join `customer` `c` on((`c`.`Customer_ID` =
`po`.`Customer_ID`))) join `person` `d` on((`c`.`Person_ID` = `d`.`Person_Id`))) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;


/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS
*/;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2016-12-12 11:57:34

You might also like