1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
delimiter $$
CREATE TABLE `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`created_date` datetime DEFAULT NULL,
`updated_date` datetime DEFAULT NULL,
`created_by` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8$$
CREATE TABLE `state` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(30) DEFAULT NULL,
`county_id` int(11) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`updated_date` datetime DEFAULT NULL,
`updated_by` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `ft_county_id` (`county_id`),
CONSTRAINT `ft_county_id` FOREIGN KEY (`county_id`) REFERENCES `country` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8$$
delimiter $$
CREATE TABLE `address` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`address1` varchar(45) NOT NULL,
`address2` varchar(45) DEFAULT NULL,
`city` varchar(45) NOT NULL,
`state_id` int(11) NOT NULL,
`country_id` int(11) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`updated_date` datetime DEFAULT NULL,
`updated_by` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8$$
CREATE TABLE `account` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`first_name` varchar(50) NOT NULL,
`last_name` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`enabled` tinyint(1) NOT NULL DEFAULT '1',
`last_login` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `account_idx1` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8$$
CREATE TABLE `client_master` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) DEFAULT NULL,
`address_id` int(11) DEFAULT NULL,
`contact_1` bigint(20) DEFAULT NULL,
`contact_2` bigint(20) DEFAULT NULL,
`contact_3` bigint(20) DEFAULT NULL,
`opening_balance` decimal(9,2) DEFAULT NULL,
`opening_balance_type` varchar(45) DEFAULT NULL,
`lock_ind` varchar(10) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`updated_date` datetime DEFAULT NULL,
`updated_by` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_address_id` (`address_id`),
CONSTRAINT `fk_address_id` FOREIGN KEY (`address_id`) REFERENCES `address` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8$$
CREATE TABLE `vehicle_owner` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) DEFAULT NULL,
`address_id` int(11) DEFAULT NULL,
`contact_1` bigint(20) DEFAULT NULL,
`contact_2` bigint(20) DEFAULT NULL,
`contact_3` bigint(20) DEFAULT NULL,
`opening_balance` decimal(9,2) DEFAULT NULL,
`opening_balance_type` varchar(45) DEFAULT NULL,
`lock_ind` varchar(45) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`updated_date` datetime DEFAULT NULL,
`updated_by` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_addr_id` (`address_id`),
CONSTRAINT `fk_addr_id` FOREIGN KEY (`address_id`) REFERENCES `address` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8$$
ALTER TABLE `transtrack`.`address` CHANGE COLUMN `update_date` `updated_date` DATETIME NULL DEFAULT NULL ;
|