Database Schema
History Key
- New content
Removed content
Recent Versions
Choose two versions to compare, or click the link to view it.
/* Database schema for Automated Courier System
*/
/* Parcel information */
drop table if exists parcels;
create table parcels (
id int not null auto_increment,
length decimal(10,2) not null,
breadth decimal(10,2) not null,
height decimal(10,2) not null,
weight decimal(10,2) not null,
description text,
value decimal(10,2),
primary key (id)
);
/* Route information for start/end countries. */
drop table if exists routes;
create table routes (
id int not null auto_increment,
start int not null,
end int not null,
foreign key (start) references countries(id),
foreign key (end) references countries(id),
primary key (id)
);
/* Country information. Lists all countries that the company serves. */
drop table if exists countries;
create table countries (
id int not null auto_increment,
name varchar(100) not null,
x int not null,
y int not null,
primary key (id)
);
/* Delivery information. Several parcels can share same route. */
drop table if exists deliveries;
create table deliveries (
id int not null auto_increment,
type varchar(20) not null,
status varchar(20) not null,
insured boolean not null,
destination text not null, /* recipient's address*/
parcel_id int not null,
customer_id int not null,
route_id int not null,
foreign key (parcel_id) references parcels(id),
foreign key (customer_id) references customers(id),
foreign key (route_id) references routes(id),
primary key (id)
);
/* User information.
Employee's exact location is determined by his current country and user type. e.g. Warehouse - Singapore
*/
drop table if exists users;
create table users (
id int not null auto_increment,
name varchar(100) not null,
password varchar(20) not null,
employeeID int not null,
user_type varchar(20) not null,
country_id int not null,
foreign key (country_id) references countries(id),
primary key (id)
);
insert into `users` (`id`, `name`, `password`, `employeeID`, `user_type`, `country_id`) values
('1', 'jm', '1', '1', 'Administrator', '1');
/* Customer information */
drop table if exists customers;
create table customers (
id int not null auto_increment,
name varchar(100) not null,
address text not null,
home_number int not null,
mobile_number int not null,
primary key (id)
);
/* Country information (long)*/
insert into `countries` (`id`, `name`, `x`, `y`) values
(1, 'Afghanistan', 0, 0),
(2, 'Albania', 0, 0),
(3, 'Algeria', 0, 0),
(4, 'American Samoa', 0, 0),
(5, 'Andorra', 0, 0),
(6, 'Angola', 0, 0),
(7, 'Anguilla', 0, 0),
(8, 'Antarctica', 0, 0),
(9, 'Antigua And Barbuda', 0, 0),
(10, 'Argentina', 0, 0),
(11, 'Armenia', 0, 0),
(12, 'Aruba', 0, 0),
(13, 'Australia', 0, 0),
(14, 'Austria', 0, 0),
(15, 'Azerbaijan', 0, 0),
(16, 'Bahamas', 0, 0),
(17, 'Bahrain', 0, 0),
(18, 'Bangladesh', 0, 0),
(19, 'Barbados', 0, 0),
(20, 'Belarus', 0, 0),
(21, 'Belgium', 0, 0),
(22, 'Belize', 0, 0),
(23, 'Benin', 0, 0),
(24, 'Bermuda', 0, 0),
(25, 'Bhutan', 0, 0),
(26, 'Bolivia', 0, 0),
(27, 'Bosnia and Herzegowina', 0, 0),
(28, 'Botswana', 0, 0),
(29, 'Bouvet Island', 0, 0),
(30, 'Brazil', 0, 0),
(31, 'British Indian Ocean Territory', 0, 0),
(32, 'Brunei Darussalam', 0, 0),
(33, 'Bulgaria', 0, 0),
(34, 'Burkina Faso', 0, 0),
(35, 'Burma', 0, 0),
(36, 'Burundi', 0, 0),
(37, 'Cambodia', 0, 0),
(38, 'Cameroon', 0, 0),
(39, 'Canada', 0, 0),
(40, 'Cape Verde', 0, 0),
(41, 'Cayman Islands', 0, 0),
(42, 'Central African Republic', 0, 0),
(43, 'Chad', 0, 0),
(44, 'Chile', 0, 0),
(45, 'China', 0, 0),
(46, 'Christmas Island', 0, 0),
(47, 'Cocos (Keeling) Islands', 0, 0),
(48, 'Colombia', 0, 0),
(49, 'Comoros', 0, 0),
(50, 'Congo', 0, 0),
(51, 'Congo, the Democratic Republic of the', 0, 0),
(52, 'Cook Islands', 0, 0),
(53, 'Costa Rica', 0, 0),
(54, 'Cote d''Ivoire', 0, 0),
(55, 'Croatia', 0, 0),
(56, 'Cuba', 0, 0),
(57, 'Cyprus', 0, 0),
(58, 'Czech Republic', 0, 0),
(59, 'Denmark', 0, 0),
(60, 'Djibouti', 0, 0),
(61, 'Dominica', 0, 0),
(62, 'Dominican Republic', 0, 0),
(63, 'East Timor', 0, 0),
(64, 'Ecuador', 0, 0),
(65, 'Egypt', 0, 0),
(66, 'El Salvador', 0, 0),
(67, 'England', 0, 0),
(68, 'Equatorial Guinea', 0, 0),
(69, 'Eritrea', 0, 0),
(70, 'Espana', 0, 0),
(71, 'Estonia', 0, 0),
(72, 'Ethiopia', 0, 0),
(73, 'Falkland Islands', 0, 0),
(74, 'Faroe Islands', 0, 0),
(75, 'Fiji', 0, 0),
(76, 'Finland', 0, 0),
(77, 'France', 0, 0),
(78, 'French Guiana', 0, 0),
(79, 'French Polynesia', 0, 0),
(80, 'French Southern Territories', 0, 0),
(81, 'Gabon', 0, 0),
(82, 'Gambia', 0, 0),
(83, 'Georgia', 0, 0),
(84, 'Germany', 0, 0),
(85, 'Ghana', 0, 0),
(86, 'Gibraltar', 0, 0),
(87, 'Great Britain', 0, 0),
(88, 'Greece', 0, 0),
(89, 'Greenland', 0, 0),
(90, 'Grenada', 0, 0),
(91, 'Guadeloupe', 0, 0),
(92, 'Guam', 0, 0),
(93, 'Guatemala', 0, 0),
(94, 'Guinea', 0, 0),
(95, 'Guinea-Bissau', 0, 0),
(96, 'Guyana', 0, 0),
(97, 'Haiti', 0, 0),
(98, 'Heard and Mc Donald Islands', 0, 0),
(99, 'Honduras', 0, 0),
(100, 'Hong Kong', 0, 0),
(101, 'Hungary', 0, 0),
(102, 'Iceland', 0, 0),
(103, 'India', 0, 0),
(104, 'Indonesia', 0, 0),
(105, 'Ireland', 0, 0),
(106, 'Israel', 0, 0),
(107, 'Italy', 0, 0),
(108, 'Iran', 0, 0),
(109, 'Iraq', 0, 0),
(110, 'Jamaica', 0, 0),
(111, 'Japan', 0, 0),
(112, 'Jordan', 0, 0),
(113, 'Kazakhstan', 0, 0),
(114, 'Kenya', 0, 0),
(115, 'Kiribati', 0, 0),
(116, 'Korea, Republic of', 0, 0),
(117, 'Korea (South)', 0, 0),
(118, 'Kuwait', 0, 0),
(119, 'Kyrgyzstan', 0, 0),
(120, 'Lao People''s Democratic Republic', 0, 0),
(121, 'Latvia', 0, 0),
(122, 'Lebanon', 0, 0),
(123, 'Lesotho', 0, 0),
(124, 'Liberia', 0, 0),
(125, 'Liechtenstein', 0, 0),
(126, 'Lithuania', 0, 0),
(127, 'Luxembourg', 0, 0),
(128, 'Macau', 0, 0),
(129, 'Macedonia', 0, 0),
(130, 'Madagascar', 0, 0),
(131, 'Malawi', 0, 0),
(132, 'Malaysia', 0, 0),
(133, 'Maldives', 0, 0),
(134, 'Mali', 0, 0),
(135, 'Malta', 0, 0),
(136, 'Marshall Islands', 0, 0),
(137, 'Martinique', 0, 0),
(138, 'Mauritania', 0, 0),
(139, 'Mauritius', 0, 0),
(140, 'Mayotte', 0, 0),
(141, 'Mexico', 0, 0),
(142, 'Micronesia, Federated States of', 0, 0),
(143, 'Moldova, Republic of', 0, 0),
(144, 'Monaco', 0, 0),
(145, 'Mongolia', 0, 0),
(146, 'Montserrat', 0, 0),
(147, 'Morocco', 0, 0),
(148, 'Mozambique', 0, 0),
(149, 'Myanmar', 0, 0),
(150, 'Namibia', 0, 0),
(151, 'Nauru', 0, 0),
(152, 'Nepal', 0, 0),
(153, 'Netherlands', 0, 0),
(154, 'Netherlands Antilles', 0, 0),
(155, 'New Caledonia', 0, 0),
(156, 'New Zealand', 0, 0),
(157, 'Nicaragua', 0, 0),
(158, 'Niger', 0, 0),
(159, 'Nigeria', 0, 0),
(160, 'Niue', 0, 0),
(161, 'Norfolk Island', 0, 0),
(162, 'Northern Ireland', 0, 0),
(163, 'Northern Mariana Islands', 0, 0),
(164, 'Norway', 0, 0),
(165, 'Oman', 0, 0),
(166, 'Pakistan', 0, 0),
(167, 'Palau', 0, 0),
(168, 'Panama', 0, 0),
(169, 'Papua New Guinea', 0, 0),
(170, 'Paraguay', 0, 0),
(171, 'Peru', 0, 0),
(172, 'Philippines', 0, 0),
(173, 'Pitcairn', 0, 0),
(174, 'Poland', 0, 0),
(175, 'Portugal', 0, 0),
(176, 'Puerto Rico', 0, 0),
(177, 'Qatar', 0, 0),
(178, 'Reunion', 0, 0),
(179, 'Romania', 0, 0),
(180, 'Russia', 0, 0),
(181, 'Rwanda', 0, 0),
(182, 'Saint Kitts and Nevis', 0, 0),
(183, 'Saint Lucia', 0, 0),
(184, 'Saint Vincent and the Grenadines', 0, 0),
(185, 'Samoa (Independent)', 0, 0),
(186, 'San Marino', 0, 0),
(187, 'Sao Tome and Principe', 0, 0),
(188, 'Saudi Arabia', 0, 0),
(189, 'Scotland', 0, 0),
(190, 'Senegal', 0, 0),
(191, 'Serbia and Montenegro', 0, 0),
(192, 'Seychelles', 0, 0),
(193, 'Sierra Leone', 0, 0),
(194, 'Singapore', 0, 0),
(195, 'Slovakia', 0, 0),
(196, 'Slovenia', 0, 0),
(197, 'Solomon Islands', 0, 0),
(198, 'Somalia', 0, 0),
(199, 'South Africa', 0, 0),
(200, 'South Georgia and the South Sandwich Islands', 0, 0),
(201, 'South Korea', 0, 0),
(202, 'Spain', 0, 0),
(203, 'Sri Lanka', 0, 0),
(204, 'St. Helena', 0, 0),
(205, 'St. Pierre and Miquelon', 0, 0),
(206, 'Suriname', 0, 0),
(207, 'Svalbard and Jan Mayen Islands', 0, 0),
(208, 'Swaziland', 0, 0),
(209, 'Sweden', 0, 0),
(210, 'Switzerland', 0, 0),
(211, 'Taiwan', 0, 0),
(212, 'Tajikistan', 0, 0),
(213, 'Tanzania', 0, 0),
(214, 'Thailand', 0, 0),
(215, 'Togo', 0, 0),
(216, 'Tokelau', 0, 0),
(217, 'Tonga', 0, 0),
(218, 'Trinidad', 0, 0),
(219, 'Trinidad and Tobago', 0, 0),
(220, 'Tunisia', 0, 0),
(221, 'Turkey', 0, 0),
(222, 'Turkmenistan', 0, 0),
(223, 'Turks and Caicos Islands', 0, 0),
(224, 'Tuvalu', 0, 0),
(225, 'Uganda', 0, 0),
(226, 'Ukraine', 0, 0),
(227, 'United Arab Emirates', 0, 0),
(228, 'United Kingdom', 0, 0),
(229, 'United States', 0, 0),
(230, 'United States Minor Outlying Islands', 0, 0),
(231, 'Uruguay', 0, 0),
(232, 'Uzbekistan', 0, 0),
(233, 'Vanuatu', 0, 0),
(234, 'Vatican City State (Holy See)', 0, 0),
(235, 'Venezuela', 0, 0),
(236, 'Viet Nam', 0, 0),
(237, 'Virgin Islands (British)', 0, 0),
(238, 'Virgin Islands (U.S.)', 0, 0),
(239, 'Wales', 0, 0),
(240, 'Wallis and Futuna Islands', 0, 0),
(241, 'Western Sahara', 0, 0),
(242, 'Yemen', 0, 0),
(243, 'Zambia', 0, 0),
(244, 'Zimbabwe', 0, 0);