0% found this document useful (0 votes)
115 views

Database and Scripts v1

The document provides details of the database design for an online bookstore, including entity relationship diagrams and descriptions of the database tables. It includes 7 tables: Admin, Customer, Delivery, Item, OrderItem, Orders. It also includes the full MySQL database script to generate the database structure and populate it with sample data.

Uploaded by

Tushar Shelake
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views

Database and Scripts v1

The document provides details of the database design for an online bookstore, including entity relationship diagrams and descriptions of the database tables. It includes 7 tables: Admin, Customer, Delivery, Item, OrderItem, Orders. It also includes the full MySQL database script to generate the database structure and populate it with sample data.

Uploaded by

Tushar Shelake
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

SIT302 Project

Database Design, Diagrams and Scripts

Online Book Store

GROUP 6
YOUSEF NAIF A ALHARBI
NOHA JAMALI A SALEM
FAISAL ABDULLAH M BIN GHIMLAS
AHMED AL SHAMISI
ABDULLAH ALDOKHIIL
Table of Contents
Table of Contents..................................................................................................................................2
1.0 Introduction.....................................................................................................................................3
1.1 Document Purpose......................................................................................................................3
2.0 Introduction.....................................................................................................................................3
2.1 Entity Relationship Diagram........................................................................................................3
3.0 Database Structure.........................................................................................................................3
3.1 Database Tables...........................................................................................................................3
3.2 Admin Table.................................................................................................................................4
3.3 Customer Table............................................................................................................................4
3.4 Delivery Table..............................................................................................................................4
3.5 Item Table....................................................................................................................................4
3.6 OrderItem Table..........................................................................................................................5
3.7 Orders Table................................................................................................................................5
4.0 Database Script................................................................................................................................5
4.1 MySQL Database Script................................................................................................................5
14.0 References...................................................................................................................................14

SIT302 Project (Group 6) Database Design and Database Scripts Page #2


1.0 Introduction
1.1 Document Purpose
The purpose of this document is to detail the database diagram, design and specifications. The
contents of this report include:
1. Entity relationship diagram
2. Database Script (generated from the MySQL database)
3. Table structures

2.0 Introduction
2.1 Entity Relationship Diagram
Source: Creating Database Entity Relationship Diagram using PHPMyAdmin (2014)

3.0 Database Structure


3.1 Database Tables

SIT302 Project (Group 6) Database Design and Database Scripts Page #3


3.2 Admin Table

3.3 Customer Table

3.4 Delivery Table

3.5 Item Table

SIT302 Project (Group 6) Database Design and Database Scripts Page #4


3.6 OrderItem Table

3.7 Orders Table

4.0 Database Script


4.1 MySQL Database Script
-- phpMyAdmin SQL Dump

-- version 4.0.9

SIT302 Project (Group 6) Database Design and Database Scripts Page #5


-- http://www.phpmyadmin.net

--

-- Host: 127.0.0.1

-- Generation Time: Nov 25, 2014 at 05:33 PM

-- Server version: 5.5.34

-- PHP Version: 5.4.22

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

SET time_zone = "+00:00";

/*!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 */;

--

-- Database: `shoppingdb`

--

-- --------------------------------------------------------

--

-- Table structure for table `admin`

--

CREATE TABLE IF NOT EXISTS `admin` (

`adminId` varchar(12) NOT NULL,

`firstName` varchar(20) DEFAULT NULL,

`lastName` varchar(45) NOT NULL,

`passWord` varchar(32) NOT NULL,

PRIMARY KEY (`adminId`)

SIT302 Project (Group 6) Database Design and Database Scripts Page #6


) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--

-- Dumping data for table `admin`

--

INSERT INTO `admin` (`adminId`, `firstName`, `lastName`, `passWord`) VALUES

('admin', 'Super', 'Administrator', '5f4dcc3b5aa765d61d8327deb882cf99');

-- --------------------------------------------------------

--

-- Table structure for table `customer`

--

CREATE TABLE IF NOT EXISTS `customer` (

`custNbr` int(10) unsigned NOT NULL AUTO_INCREMENT,

`email` varchar(50) NOT NULL,

`firstName` varchar(20) DEFAULT NULL,

`lastName` varchar(45) NOT NULL,

`dateJoined` date NOT NULL,

`address1` varchar(45) NOT NULL,

`address2` varchar(45) DEFAULT NULL,

`suburb` varchar(45) NOT NULL,

`state` enum('ACT','NSW','NT','QLD','SA','TAS','VIC','WA') NOT NULL,

`postCode` int(10) unsigned NOT NULL,

`passWord` varchar(32) NOT NULL,

PRIMARY KEY (`custNbr`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

--

-- Dumping data for table `customer`

SIT302 Project (Group 6) Database Design and Database Scripts Page #7


--

INSERT INTO `customer` (`custNbr`, `email`, `firstName`, `lastName`, `dateJoined`,


`address1`, `address2`, `suburb`, `state`, `postCode`, `passWord`) VALUES

(1, '[email protected]', 'John', 'Wind', '2012-04-01', '20 Burke Street', '',


'Melbourne', 'VIC', 3000, '3bffe7a2bc163d273184e8902afe66b7'),

(2, '[email protected]', 'Mary', 'Jane', '2013-02-11', '30 Bulls Drive', NULL,


'Perth', 'WA', 6000, 'a5446c2cfe2b8a015caa8a7e825bb8af'),

(3, '[email protected]', 'First', 'Last', '2011-05-15', '18 Heidelberg Road',


NULL, 'Panorama', 'ACT', 5041, '17ed325d1311df2929d0135e2115297c'),

(4, '[email protected]', 'Jenny', 'Fo', '2000-05-11', '50 Kilmore Avenue', NULL,


'Reservoir', 'VIC', 3072, '8f6679cbc69eba8d8f819352a5919ab9'),

(5, '[email protected]', 'Michael', 'Nelson', '2002-01-14', '10 Epping Road',


NULL, 'Hobart', 'TAS', 7000, '8ba119932b97b45d0c96817af8babcca'),

(6, '[email protected]', 'Ahme', 'Alshamisi', '2013-04-07', '15 Flinders Street',


'', 'Melbourne', 'VIC', 3072, 'd8578edf8458ce06fbc5bb76a58c5ca4'),

(7, '[email protected]', 'TestFirstName', 'TestLastName', '2013-04-10', 'Test Line1',


'Test Line2', 'Test Suburb', 'ACT', 3000, 'e16b2ab8d12314bf4efbd6203906ea6c'),

(8, '[email protected]', 'test', 'test', '2013-04-10', 'test', 'test', 'test', 'SA',


3000, '098f6bcd4621d373cade4e832627b4f6');

-- --------------------------------------------------------

--

-- Table structure for table `delivery`

--

CREATE TABLE IF NOT EXISTS `delivery` (

`deliveryState` enum('ACT','NSW','NT','QLD','SA','TAS','VIC','WA') NOT NULL,

`deliveryRate` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',

PRIMARY KEY (`deliveryState`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--

-- Dumping data for table `delivery`

--

SIT302 Project (Group 6) Database Design and Database Scripts Page #8


INSERT INTO `delivery` (`deliveryState`, `deliveryRate`) VALUES

('ACT', '6.00'),

('NSW', '5.50'),

('NT', '9.50'),

('QLD', '5.50'),

('SA', '15.50'),

('TAS', '8.50'),

('VIC', '5.50'),

('WA', '7.50');

-- --------------------------------------------------------

--

-- Table structure for table `item`

--

CREATE TABLE IF NOT EXISTS `item` (

`itemCode` varchar(10) NOT NULL,

`itemName` varchar(25) NOT NULL,

`description` varchar(255) NOT NULL,

`category` enum('FICTION','SCIENCE','HEALTH','HISTORY','COMICS') NOT NULL,

`qtyOnHand` int(11) NOT NULL DEFAULT '0',

`unitPrice` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',

`photo1` varchar(50) NOT NULL,

`photo2` varchar(50) DEFAULT NULL,

`photo3` varchar(50) DEFAULT NULL,

`thumbNail` varchar(50) NOT NULL,

`featured` tinyint(1) NOT NULL,

PRIMARY KEY (`itemCode`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

SIT302 Project (Group 6) Database Design and Database Scripts Page #9


--

-- Dumping data for table `item`

--

INSERT INTO `item` (`itemCode`, `itemName`, `description`, `category`, `qtyOnHand`,


`unitPrice`, `photo1`, `photo2`, `photo3`, `thumbNail`, `featured`) VALUES

('A001', 'Nineteen Eighty-Four', '''Who controls the past controls the future: who
controls the present controls the past'' Hidden away in the Record Department of
the sprawling Ministry of Truth, Winston Smith skilfully rewrites the past to suit
the needs of the Party.', 'FICTION', 200, '27.50', 'book1.jpg', 'book6.jpg',
'book5.jpg', 'book1Thumb.jpg', 1),

('A002', 'Dune', 'Dune tells the story of young Paul Atreides, the heir apparent to
Duke Leto Atreides as his family accepts control of the desert planet Arrakis, the
only source of the ''spice'' melange.', 'FICTION', 250, '30.20', 'book2.jpg', NULL,
NULL, 'book2Thumb.jpg', 1),

('A003', 'Harry Potter and the Deat', 'Harry Potter and the Deathly Hallows is the
seventh and final of the Harry Potter novels. The novel chronicles the events
directly following Harry Potter and the Half-Blood Prince (2005), and the final
confrontation between the wizards Harry Potter and Lo', 'FICTION', 100, '20.00',
'book3.jpg', NULL, NULL, 'book3Thumb.jpg', 0),

('A004', 'A Tale of Two Cities', 'A Tale of Two Cities is a novel by Charles
Dickens, set in London and Paris before and during the French Revolution.',
'FICTION', 229, '26.00', 'book4.jpg', NULL, NULL, 'book4Thumb.jpg', 0),

('A005', 'A Brief History of Time', 'A Brief History of Time attempts to explain a
range of subjects in cosmology, including the Big Bang, black holes and light
cones, to the nonspecialist reader.', 'SCIENCE', 89, '26.00', 'book5.jpg', NULL,
NULL, 'book5Thumb.jpg', 0),

('A006', 'The Selfish Gene', 'The Selfish Gene is a book on evolution by Richard
Dawkins, published in 1976. It builds upon the principal theory of George C.
Williams''s first book Adaptation and Natural Selection.', 'SCIENCE', 98, '20.00',
'book6.jpg', NULL, NULL, 'book6Thumb.jpg', 0),

('A007', 'The World Without Us', 'The World Without Us is a non-fiction book about
what would happen to the natural and built environment if humans suddenly
disappeared, written by American journalist Alan Weisman.', 'SCIENCE', 105,
'23.00', 'book7.jpg', NULL, NULL, 'book7Thumb.jpg', 0),

('A008', 'The Blind Watchmaker', 'The Blind Watchmaker: Why the Evidence of
Evolution Reveals a Universe without Design is a 1986 book by Richard Dawkins in
which he presents an explanation of, and argument for, the theory of evolution by
means of natural selection.', 'SCIENCE', 125, '39.00', 'book8.jpg', NULL, NULL,
'book8Thumb.jpg', 0),

('A009', 'Ontogeny and Phylogeny', 'Ontogeny and Phylogeny explores the


relationship between embryonic development (ontogeny) and biological evolution
(phylogeny)', 'SCIENCE', 134, '18.00', 'book9.jpg', NULL, NULL, 'book9Thumb.jpg',
0),

('A010', 'The Magic of Reality', 'How We Know What''s Really True is a 2011 book by
British biologist Richard Dawkins, with illustrations by Dave McKean.', 'SCIENCE',
118, '23.00', 'book10.jpg', NULL, NULL, 'book10Thumb.jpg', 0),

SIT302 Project (Group 6) Database Design and Database Scripts Page #10
('A011', 'Perfect Health', 'A decade ago, Deepak Chopra, M.D., wrote Perfect
Health, the first practical guide to harnessing the healing power of the mind,
which became a national bestseller.', 'HEALTH', 53, '45.00', 'book11.jpg', NULL,
NULL, 'book11Thumb.jpg', 0),

('A012', 'Healing Yourself! 23 Ways', 'This is a book for individuals with an


earnest desire to alter their health and to become a positive active healing force
in their own or another''s life.', 'HEALTH', 20, '15.00', 'book12.jpg', NULL, NULL,
'book12Thumb.jpg', 1),

('A013', 'Lies My Teacher Told Me', 'Lies My Teacher Told Me: Everything Your
American History Textbook Got Wrong is a 1995 book by sociologist James Loewen.',
'HISTORY', 62, '45.00', 'book13.jpg', NULL, NULL, 'book13Thumb.jpg', 0),

('A014', 'OUR SUNBURNT COUNTRY', 'Our Sunburnt Country: An illustrated history of


Australia tells the story of Australia''s heritage, from Aboriginal settlement
until the present.', 'HISTORY', 500, '24.99', 'book14.jpg', NULL, NULL,
'book14Thumb.jpg', 0),

('A015', 'Australian Legends', 'This book, covers the development of the Australian
Quarter Horse history, which began a relatively short time ago with the 1954
arrival of the first four King Ranch stallions – Vaquero, Jackaroo, Gold
Standard and Mescal.', 'HISTORY', 40, '10.99', 'book15.jpg', NULL, NULL,
'book15Thumb.jpg', 0),

('A016', 'The Walking Dead', 'Popularized by the hit AMC television show, the
series follows a band of survivors struggling to live from one day to the next
amidst a zombie apocalypse.', 'COMICS', 500, '15.50', 'book16.jpg', NULL, NULL,
'book16Thumb.jpg', 0),

('A017', 'Batman', 'Revitalized in 2011 through DC comic’s “New 52?


initiative, Bruce Wayne is back in black, ever vigilant for crimes on GothamÃ
¢â‚¬â„¢s streets.', 'COMICS', 400, '15.50', 'book17.jpg', NULL, NULL,
'book17Thumb.jpg', 0),

('A018', 'Saga', 'Borrowing elements from both science-fiction and fantasy, two
star-crossed lovers escape across the galaxy amidst a war between worlds.',
'COMICS', 200, '15.50', 'book18.jpg', NULL, NULL, 'book18Thumb.jpg', 0),

('A019', 'Justice League of America', 'Starring DC’s entire cast of heroes


and villains, the series serves as a link between all of DC’s other printed
issues in exploring the dynamics between its characters.', 'COMICS', 200, '18.50',
'book19.jpg', NULL, NULL, 'book19Thumb.jpg', 0),

('A020', 'The Superior Spider-Man', 'After Peter Parker’s death in Ã


¢â‚¬Å“The Amazing Spider-Man”s 700th issue, Marvel brought a new Spider-Man
into the fray to carry on the web-slinging legacy.', 'COMICS', 800, '24.99',
'book20.jpg', NULL, NULL, 'book20Thumb.jpg', 0),

('NEWBOOK', 'New Book', 'Item Description', 'FICTION', 5, '50.00',


'apache_pb2.png', NULL, NULL, 'testThumbNail', 1);

-- --------------------------------------------------------

--

-- Table structure for table `ordereditem`

SIT302 Project (Group 6) Database Design and Database Scripts Page #11
--

CREATE TABLE IF NOT EXISTS `ordereditem` (

`orderNbr` int(10) unsigned NOT NULL,

`itemCode` varchar(10) NOT NULL,

`qtyOrdered` int(10) unsigned NOT NULL,

`sellingPrice` decimal(10,2) unsigned NOT NULL,

PRIMARY KEY (`orderNbr`,`itemCode`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--

-- Dumping data for table `ordereditem`

--

INSERT INTO `ordereditem` (`orderNbr`, `itemCode`, `qtyOrdered`, `sellingPrice`)


VALUES

(5, 'A001', 2, '27.50'),

(5, 'A005', 1, '26.00'),

(6, 'A001', 2, '27.50'),

(6, 'A008', 1, '39.00');

-- --------------------------------------------------------

--

-- Table structure for table `orders`

--

CREATE TABLE IF NOT EXISTS `orders` (

`orderNbr` int(10) unsigned NOT NULL AUTO_INCREMENT,

`custNbr` int(10) unsigned NOT NULL,

`orderDate` date NOT NULL,

`dispatchDate` date DEFAULT NULL,

`deliveryDate` date DEFAULT NULL,

SIT302 Project (Group 6) Database Design and Database Scripts Page #12
`orderNetValue` decimal(10,2) unsigned NOT NULL,

`deliverTo` varchar(60) NOT NULL,

`deliveryAddress1` varchar(45) NOT NULL,

`deliveryAddress2` varchar(45) DEFAULT NULL,

`deliverySuburb` varchar(45) NOT NULL,

`deliveryState` enum('ACT','NSW','NT','QLD','SA','TAS','VIC','WA') NOT NULL,

`deliveryPostCode` int(10) unsigned NOT NULL,

`deliveryInstructions` varchar(255) DEFAULT NULL,

`deliveryValue` decimal(10,2) unsigned NOT NULL,

`paymentType` enum('VC','MC','BP','PP','AE','DC') NOT NULL,

`paymentRef` varchar(40) NOT NULL,

PRIMARY KEY (`orderNbr`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--

-- Dumping data for table `orders`

--

INSERT INTO `orders` (`orderNbr`, `custNbr`, `orderDate`, `dispatchDate`,


`deliveryDate`, `orderNetValue`, `deliverTo`, `deliveryAddress1`,
`deliveryAddress2`, `deliverySuburb`, `deliveryState`, `deliveryPostCode`,
`deliveryInstructions`, `deliveryValue`, `paymentType`, `paymentRef`) VALUES

(5, 6, '2013-04-10', '2013-04-10', '2013-04-12', '81.00', 'Aanchal ', '30 Woolnough


Drive', '', 'Mill Park', 'VIC', 3083, '', '5.50', 'MC', 'B093N2xVgFqVQQpNS4AJ'),

(6, 6, '2013-04-10', '2013-04-10', '2013-04-12', '94.00', 'Aanchal ', '30 Woolnough


Drive', 'Line', 'Mill Park', 'WA', 3083, 'No Instructions', '7.50', 'MC',
'N7MTGufXt9jxqVWcd9B4');

/*!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 */;

SIT302 Project (Group 6) Database Design and Database Scripts Page #13
14.0 References
PHP MyAdmin Tool, used to generate database scripts

SIT302 Project (Group 6) Database Design and Database Scripts Page #14

You might also like