You are on page 1of 9

Inventory Management System

CST 363
Spring 2015
Terrence Johnson
Dean Cowart
Alex Westerlund

Purpose

Manage inventory
Employee Accountability

Tables
Employee
Shift
Inventory
Kits

Primary Keys
item_id
shift_id
kit_id
employee_id

Foreign Keys
shift_id
kit_id

ER Diagram

Views
CREATE VIEW out_of_stock AS
SELECT item_name, kit_type
FROM `inventory` i
inner join kits k
on i.kit_id = k.kit_id
where in_stock < 5

DDL Scripts
CREATE TABLE IF NOT EXISTS `employee` ( `employee_id` int(3) NOT NULL AUTO_INCREMENT, `employee_name` varchar(30) NOT NULL,
`kit_id` int(1) NOT NULL, `total` int(3) NOT NULL, `shift_id` int(1) NOT NULL,
PRIMARY KEY (`employee_id`),
UNIQUE KEY `kits` (`kit_id`),
FOREIGN KEY ('shift_id')
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
CREATE TABLE IF NOT EXISTS `kits` (`kit_id` int(255) NOT NULL AUTO_INCREMENT, `kit type` varchar(100) NOT NULL,
`in_stock` int(255) NOT NULL, `ordered` int(255) NOT NULL, `possible` int(255) NOT NULL,
PRIMARY KEY (`kit_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
CREATE TABLE IF NOT EXISTS `shift` (`shift_id` int(15) NOT NULL AUTO_INCREMENT,
`shift_begin` varchar(10) NOT NULL, `shift_end` varchar(10) NOT NULL,
PRIMARY KEY (`shift_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
CREATE TABLE IF NOT EXISTS `inventory` (`item_id` int(255) NOT NULL AUTO_INCREMENT, `item_name` varchar(40) NOT NULL,
`kit_id` int(1) NOT NULL, `in_stock` int(255) NOT NULL, `ordered` int(255) NOT NULL,
PRIMARY KEY (`item_id`),
FOREIGN KEY (`kit_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=52 ;

DML Scripts
INSERT INTO `inventory` (`item_id`, `item_name`, `kit_id`, `in_stock`, `ordered`) VALUES
(1, 'Power Cable(18/6 in ft.)', 1, 700, 0),
(2, 'Red and Black Power Cable', 1, 1800, 0),
(3, 'Control Box', 1, 0, 480)
INSERT INTO `shift` (`shift_id`, `shift_begin`, `shift_end`) VALUES
(1, '08:00', '13:00'),
(2, '12:00', '18:00');
INSERT INTO `kits` (`kit_id`, `kit type`, `in_stock`, `ordered`, `possible`) VALUES
(1, 'Pufferfish kit', 0, 180, 0),
(2, 'Triggerfish Kit', 0, 0, 0),
(3, 'Pufferfish and Triggerfish Kits', 0, 0, 0);
INSERT INTO `employee` (`employee_id`, `employee_name`, `kit_id`, `total`, `shift_id`) VALUES
(1, 'Dean', 2, 30, 1),
(2, Alex, 2, 30, 2);

You might also like