The ERD showed in figure 1 above is modelled based on the following assumptions and extensions to the provided case study.
Normalization
The normalization process involved performing the following checks on each entity from the entity relationship diagram.
Normalization of the entities is done using bottom up approach for all the entities specified in the entity relation diagram. Thus to demonstrate the normalization process for each entity involves the following steps;
Lease (leaseID, itemID, period, client, cost)
Expert (expertID, firstName, lastName, type, email, phone, addres)
Question 3
Implementation of the database was done MySQL which is accessed from PHPMyAdmin using a browser. Below is the code for each table and a screenshot of the structure of the table.
Code
— User Id: 227171
create table category(
categoryID integer primary key,
name varchar(50) not null
Code
— User Id: 227171
create table item(
itemID integer primary key,
categoryID integer not null,
name varchar(50) not null,
costPrice decimal(10,2) not null,
sellingPrice decimal(10,2) not null,
description varchar(500) not null,
foreign key (categoryID) references category (categoryID),
check (costprice>0),
check (sellingPrice>0)
Code
— User Id: 227171
create table seller(
sellerID integer primary key,
firstName varchar(50) not null,
lastname varchar(50) not null,
phoneNo varchar(25) not null,
email varchar(50) null,
type varchar(25) not null
Code
— User Id: 227171
create table buyer(
buyerID integer primary key,
firstName varchar(50) not null,
lastname varchar(50) not null,
phoneNo varchar(25) not null,
email varchar(50) null
Table sales
Code
— User Id: 227171
create table sales(
saleID integer primary key,
saleDate date not null,
buyerID integer not null,
foreign key (buyerID) references buyer (buyerID)
Code
— User Id: 227171
create table purchases(
purchaseID integer primary key,
purchaseDate date not null,
sellerID integer not null,
foreign key (sellerID) references seller (sellerID)
Code
— User Id: 227171
create table sales_items(
saleID integer not null,
itemID integer not null,
primary key (saleID,itemID),
foreign key (saleID) references sales(saleID),
foreign key (itemID) references item (itemID)
Code
— User Id: 227171
create table purchases_items(
purchaseID integer not null,
itemID integer not null,
primary key (purchaseID,itemID),
foreign key (purchaseID) references purchases(purchaseID),
foreign key (itemID) references item (itemID)
Code
— User Id: 227171
create table expert(
expertID integer primary key,
firstName varchar(50) not null,
lastName varchar(50) not null,
type varchar(15) not null,
email varchar(50) not null,
phone varchar(15) not null,
address varchar(100) not null,
check (type in (‘repairer’,’restorer’,’valuer’))
Code
— User Id: 227171
create table item_actions(
actionID integer primary key,
itemID integer not null,
dateDone date not null,
expertID integer not null,
cost decimal(10,2) not null,
type varchar(15) not null,
foreign key (itemID) references item (itemID),
foreign key (expertID) references expert (expertID)
Code
— User Id: 227171
create table lease(
leaseID integer primary key,
itemID integer not null,
leaseDate date not null,
period integer not null,
client varchar(50) not null,
cost decimal (10,2) not null,
foreign key (itemID) references item (itemID)
Code
— User Id: 227171
create table staff(
staffID integer primary key,
firstname varchar(50) not null,
lastname varchar(50) not null,
email varchar(50) not null,
phone varchar(50) not null,
position varchar(50) not null
Code
— User Id: 227171
create table expenses(
expenseID integer primary key,
type varchar(25) not null,
amount decimal(10,2) not null,
expenseDate date not null,
staffID integer not null,
foreign key (staffID) references staff (staffID)
Code
— User Id: 227171
create table collection(
collectionID integer primary key,
itemID integer not null,
dateRetained date not null,
staffID integer not null,
foreign key (staffID) references staff (staffID),
foreign key (itemID) references item (itemID)
Code
— User Id: 227171
create table payment(
paymentID integer primary key,
expenseID integer not null,
paymentMethod varchar(30) not null default ‘cash’,
foreign key (expenseID) references expenses (expenseID)
Question 4
Populating the tables with fictional data.
Code
INSERT INTO `antiques`.`category` (`categoryID`, `name`) VALUES (‘1’, ‘Militaria’), (‘2’, ‘Furniture’), (‘3’, ‘Clothing’), (‘4’, ‘clocks & watches’), (‘5’, ‘Optical’), (‘6’, ‘electrical’), (‘7’, ‘sporting’), (‘8’, ‘motors’), (‘9’, ‘assorted’);
Item table
Code
INSERT INTO `antiques`.`item` (`itemID`, `categoryID`, `name`, `costPrice`, `sellingPrice`, `description`) VALUES (‘1’, ‘1’, ‘ak 47’, ‘120’, ‘150’, ‘ak 47 ancient world war 2 riffle’), (‘2’, ‘2’, ‘1 seater chair’, ’50’, ’80’, ‘a good relaxation chair’), (‘3’, ‘3’, ‘Cap’, ’15’, ’20’, ‘a good ancient chinese cap’), (‘4’, ‘4’, ‘Rolex watch’, ‘200’, ‘250’, ‘rolex watch’), (‘5’, ‘4’, ‘Rolex wall clock’, ‘150’, ‘180’, ‘A good old rolex wall clock’), (‘6’, ‘6’, ‘optical telescope’, ’80’, ’90’, ‘a good old stelescope’), (‘7’, ‘7’, ‘cooker’, ‘123’, ‘154’, ‘ancient cooker with oven’), (‘8’, ‘8’, ‘football’, ’50’, ’70’, ‘Lionel Messis first football’), (‘9’, ‘8’, ‘bm3 320 i gt’, ‘3000’, ‘4000’, ‘buy and drive old school BMW’), (’10’, ‘9’, ‘sculpture’, ‘300’, ‘350’, ‘ancient rome sculpture’);
Seller table
Code
INSERT INTO `antiques`.`seller` (`sellerID`, `firstName`, `lastname`, `phoneNo`, `email`, `type`) VALUES (‘1’, ‘Peter’, ‘Griffin’, ‘+2332332432’, ‘[email protected]‘, ‘individual’), (‘2’, ‘Lois’, ‘Griffin’, ‘+2343243242’, ‘[email protected]‘, ‘individual’), (‘3’, ‘Stewie’, ‘Griffin’, ‘+32432423’, ‘[email protected]‘, ‘individual’), (‘4’, ‘Brian ‘, ‘Girffiin’, ‘+223423423’, ‘[email protected]‘, ‘individual’), (‘5’, ‘Meg’, ‘Griffin’, ‘+32423232’, ‘[email protected]‘, ‘individual’), (‘6’, ‘Cleveland’, ‘Brown’, ‘+23211312’, ‘[email protected]‘, ‘individual’), (‘7’, ‘Cleveland’, ‘Jr’, ‘+24342323’, ‘[email protected]‘, ‘individual’), (‘8’, ‘Rallo’, ‘tabbs’, ‘+43423423’, ‘[email protected]‘, ‘individual’), (‘9’, ‘ROberta’, ‘tabbs’, ‘+3243423423’, ‘[email protected]‘, ‘indivual’), (’10’, ‘labada’, ‘tabbs’, ‘+234234232’, ‘[email protected]‘, ‘individual’);
Code
INSERT INTO `antiques`.`buyer` (`buyerID`, `firstName`, `lastname`, `phoneNo`, `email`) VALUES (‘1’, ‘Lebron’, ‘James’, ‘+344342232’, ‘[email protected]‘), (‘2’, ‘Brandon’, ‘Ingram’, ‘+43434423’, ‘[email protected]‘), (‘3’, ‘Rajon’, ‘Rondo’, ‘[email protected]‘, ‘+3444343434’), (‘4’, ‘Lonzo’, ‘Ball’, ‘+343434343’, ‘[email protected]‘), (‘5’, ‘Lance ‘, ‘steph’, ‘+34343434’, ‘[email protected]‘), (‘6’, ‘Kyle’, ‘Kuzma’, ‘+34343434’, ‘[email protected]‘), (‘7’, ‘Josh’, ‘Hart’, ‘+43434232332’, ‘[email protected]‘), (‘8’, ‘Chris’, ‘Paul’, ‘+334343243’, ‘[email protected]‘), (‘9’, ‘Carmello’, ‘ANthony’, ‘+34432434’, ‘[email protected]‘), (’10’, ‘James’, ‘Harden’, ‘+43434234’, ‘[email protected]‘);
Code
INSERT INTO `antiques`.`sales` (`saleID`, `saleDate`, `buyerID`) VALUES (‘1’, ‘2018-10-09’, ‘1’), (‘2’, ‘2018-10-10’, ‘1’), (‘3’, ‘2018-10-10’, ‘3’), (‘4’, ‘2018-10-10’, ‘4’), (‘5’, ‘2018-10-10’, ‘5’), (‘6’, ‘2018-10-10’, ‘6’), (‘7’, ‘2018-10-10’, ‘8’), (‘8’, ‘2018-10-10’, ‘8’), (‘9’, ‘2018-10-10’, ‘9’), (’10’, ‘2018-10-10′, ’10’);
Code
INSERT INTO `antiques`.`sales_items` (`saleID`, `itemID`) VALUES (‘1’, ‘1’), (‘1’, ‘2’), (‘2’, ‘3’), (‘3’, ‘3’), (‘4’, ‘5’), (‘6’, ‘7’), (‘7’, ‘8’), (‘9’, ‘9’), (‘9′, ’10’), (’10’, ’10’);
Code
INSERT INTO `antiques`.`purchases` (`purchaseID`, `purchaseDate`, `sellerID`) VALUES (‘1’, ‘2018-10-27’, ‘1’), (‘2’, ‘2018-10-31’, ‘2’), (‘3’, ‘2018-10-31’, ‘3’), (‘4’, ‘2018-10-31’, ‘4’), (‘5’, ‘2018-10-31’, ‘5’), (‘6’, ‘2018-10-31’, ‘6’), (‘7’, ‘2018-10-31’, ‘7’), (‘8’, ‘2018-10-31’, ‘8’), (‘9’, ‘2018-10-31′, ’10’), (’10’, ‘2018-10-31′, ’10’);
Code
INSERT INTO `antiques`.`purchases_items` (`purchaseID`, `itemID`) VALUES (‘1’, ‘1’), (‘2’, ‘2’), (‘3’, ‘3’), (‘4’, ‘4’), (‘5’, ‘5’), (‘6’, ‘6’), (‘7’, ‘7’), (‘8’, ‘8’), (‘9’, ‘9’), (’10’, ’10’);
Code
INSERT INTO `antiques`.`expert` (`expertID`, `firstName`, `lastName`, `type`, `email`, `phone`, `address`) VALUES (‘1’, ‘Kyrie ‘, ‘Irving’, ‘valuer’, ‘[email protected]‘, ‘+343423423’, ‘cletics td garden’), (‘2’, ‘terry’, ‘Rozier’, ‘valuer’, ‘[email protected]‘, ‘+324234234’, ‘td garden, celtics’), (‘3’, ‘Jaylen’, ‘Brown’, ‘valuer’, ‘[email protected]‘, ‘+223423434’, ‘td cgarden, celtics’), (‘4’, ‘Gordon’, ‘Hayward’, ‘restorer’, ‘[email protected]‘, ‘+3244342’, ‘td garden celtics’), (‘5’, ‘Al’, ‘Hroford’, ‘restorer’, ‘[email protected]‘, ‘+3223232’, ‘td garden,celtics’), (‘6’, ‘Marcus’, ‘Smart’, ‘restorer’, ‘[email protected]‘, ‘+32234234’, ‘td garden, celtics’), (‘7’, ‘Markeif’, ‘Morris’, ‘repairer’, ‘[email protected]‘, ‘+32342342’, ‘td garden celtics’), (‘8’, ‘Jayson’, ‘Tatum’, ‘repairer’, ‘[email protected]‘, ‘+23312321’, ‘td garden celtics’), (‘9’, ‘Jr’, ‘smith’, ‘repairer’, ‘[email protected]‘, ‘+2332343’, ‘quick loans arena’), (’10’, ‘kevin’, ‘Love’, ‘repairer’, ‘[email protected]‘, ‘+334334’, ‘quick loans arena’);
Lease table
Code
INSERT INTO `antiques`.`lease` (`leaseID`, `itemID`, `leaseDate`, `period`, `client`, `cost`) VALUES (‘1’, ‘1’, ‘2018-10-17’, ‘2’, ‘Marvel’, ‘300’), (‘2’, ‘2’, ‘2018-10-18’, ‘3’, ‘Warner Bros’, ‘400’), (‘3’, ‘3’, ‘2018-10-18’, ‘3’, ‘Warner Bros’, ‘500’), (‘4’, ‘4’, ‘2018-10-18’, ‘4’, ‘Netflix’, ‘434’), (‘5’, ‘5’, ‘2018-10-18’, ‘4’, ‘universal’, ‘432’), (‘6’, ‘6’, ‘2018-10-18’, ‘4’, ‘universal’, ‘3434’), (‘7’, ‘7’, ‘2018-10-18’, ‘4’, ‘Columbia ‘, ‘323’), (‘8’, ‘8’, ‘2018-10-18’, ‘4’, ‘Sony’, ‘3422’), (‘9’, ‘9’, ‘2018-10-18’, ‘2’, ‘Sony’, ‘342’), (’10’, ’10’, ‘2018-10-18’, ‘2’, ‘Warner Bros’, ‘2432’);
Code
INSERT INTO `antiques`.`staff` (`staffID`, `firstname`, `lastname`, `email`, `phone`, `position`) VALUES (‘1’, ‘Steph’, ‘curry’, ‘[email protected]‘, ‘+33434323’, ‘manager’), (‘2’, ‘Demarcus’, ‘cousins’, ‘[email protected]‘, ‘+3343423’, ‘assisttant manager’), (‘3’, ‘Klay’, ‘Thompson’, ‘[email protected]‘, ‘[email protected]‘, ‘salesperson’), (‘4’, ‘kevin’, ‘Durant’, ‘[email protected]‘, ‘+43434334’, ‘salesperson’), (‘5’, ‘Jon’, ‘smith’, ‘[email protected]‘, ‘+4343434’, ‘salesperson’), (‘6’, ‘Mike’, ‘Looney’, ‘[email protected]‘, ‘+4343432’, ‘field agent’), (‘7’, ‘Danerys’, ‘Teagryn’, ‘khaleesi’, ‘[email protected]‘, ‘field agent’), (‘8’, ‘khal’, ‘drogo’, ‘[email protected]‘, ‘+4343423’, ‘salesperson’), (‘9’, ‘Brianner’, ‘Tarth’, ‘[email protected]‘, ‘+324234324’, ‘salesperson’), (’10’, ‘Jon’, ‘White’, ‘[email protected]‘, ‘+4343434’, ‘salesperson’);
Item-actions table
Code
INSERT INTO `antiques`.`item_actions` (`actionID`, `itemID`, `dateDone`, `expertID`, `cost`, `type`) VALUES (‘1’, ‘1’, ‘2018-10-09’, ‘1’, ‘322’, ‘valuation’), (‘2’, ‘2’, ‘2018-10-26’, ‘3’, ‘232’, ‘valuation’), (‘3’, ‘3’, ‘2018-10-26’, ‘3’, ‘323’, ‘valuation’), (‘4’, ‘4’, ‘2018-10-26’, ‘4’, ’32’, ‘repair’), (‘5’, ‘5’, ‘2018-10-26’, ‘5’, ‘232’, ‘repair’), (‘6’, ‘6’, ‘2018-10-26’, ‘6’, ‘233’, ‘repair’), (‘7’, ‘7’, ‘2018-10-26’, ‘7’, ‘232’, ‘restoration’), (‘8’, ‘8’, ‘2018-10-26’, ‘8’, ’32’, ‘restoration’), (‘9’, ‘9’, ‘2018-10-26’, ‘9’, ‘232’, ‘restoration’), (’10’, ’10’, ‘2018-10-26′, ’10’, ‘223’, ‘restoration’);
Code
INSERT INTO `antiques`.`collection` (`collectionID`, `itemID`, `dateRetained`, `staffID`) VALUES (‘1’, ‘1’, ‘2018-10-23’, ‘1’), (‘2’, ‘2’, ‘2018-10-17’, ‘2’), (‘3’, ‘3’, ‘2018-10-17’, ‘3’), (‘4’, ‘4’, ‘2018-10-17’, ‘4’), (‘5’, ‘5’, ‘2018-10-17’, ‘5’), (‘6’, ‘6’, ‘2018-10-17’, ‘6’), (‘7’, ‘7’, ‘2018-10-17’, ‘7’), (‘8’, ‘8’, ‘2018-10-17’, ‘8’), (‘9’, ‘9’, ‘2018-10-17’, ‘9’), (’10’, ’10’, ‘2018-10-17′, ’10’)
Code
INSERT INTO `antiques`.`expenses` (`expenseID`, `type`, `amount`, `expenseDate`, `staffID`) VALUES (‘1’, ‘accomodation’, ‘233’, ‘2018-10-09’, ‘1’), (‘2’, ‘accomodation’, ‘2324’, ‘2018-10-09’, ‘2’), (‘3’, ‘fuel’, ‘3223’, ‘2018-10-09’, ‘3’), (‘4’, ‘fuel’, ‘2323’, ‘2018-10-09’, ‘4’), (‘5’, ‘acommodation’, ‘2324’, ‘2018-10-09’, ‘5’), (‘6’, ‘accommodation’, ‘323’, ‘2018-10-09’, ‘6’), (‘7’, ‘accommodation’, ‘23443’, ‘2018-10-09’, ‘8’), (‘8’, ‘accommodation’, ‘432’, ‘2018-10-09’, ‘8’), (‘9’, ‘acommodation’, ‘3232’, ‘2018-10-09’, ‘9’), (’10’, ‘fuel’, ‘334’, ‘2018-10-09′, ’10’);
Code
INSERT INTO `antiques`.`payment` (`paymentID`, `expenseID`, `paymentMethod`) VALUES (‘1’, ‘1’, ‘cash’), (‘2’, ‘2’, ‘cash’), (‘3’, ‘3’, ‘cash’), (‘4’, ‘4’, ‘cash’), (‘5’, ‘5’, ‘cash’), (‘6’, ‘6’, ‘cash’), (‘7’, ‘7’, ‘cash’), (‘8’, ‘8’, ‘cash’), (‘9’, ‘9’, ‘cash’), (’10’, ’10’, ‘cash’);
Question 5
Queries
1.
Code
— User Id: 227171
select * from item_actions where type=’valuation’;
2.
Code
— User Id: 227171
select * from sales where saledate<curdate();
3.
Code
— User Id: 227171
select paymentMethod,count(paymentID) from payment;
4.
Code
— User Id: 227171
select sum(amount) from expenses;
5.
Code
— User Id: 227171
select firstname,lastname,expensedate from expenses inner join staff on staff.staffID=expenses.staffID ;
6.
Code
— User Id: 227171
select * from item_actions group by type;
7.
Code
— User Id: 227171
select * from staff where staffID in (select staffID from expenses);
Code
— User Id: 227171
select * from staff where staffID not in (select staffID from expenses);
9.
Code
— User Id: 227171
select min(amount) from expenses;
10.
Code
— User Id: 227171
select * from expenses having max(amount);
Essay Writing Service Features
Our Experience
No matter how complex your assignment is, we can find the right professional for your specific task. Contact Essay is an essay writing company that hires only the smartest minds to help you with your projects. Our expertise allows us to provide students with high-quality academic writing, editing & proofreading services.Free Features
Free revision policy
$10Free bibliography & reference
$8Free title page
$8Free formatting
$8How Our Essay Writing Service Works
First, you will need to complete an order form. It's not difficult but, in case there is anything you find not to be clear, you may always call us so that we can guide you through it. On the order form, you will need to include some basic information concerning your order: subject, topic, number of pages, etc. We also encourage our clients to upload any relevant information or sources that will help.
Complete the order formOnce we have all the information and instructions that we need, we select the most suitable writer for your assignment. While everything seems to be clear, the writer, who has complete knowledge of the subject, may need clarification from you. It is at that point that you would receive a call or email from us.
Writer’s assignmentAs soon as the writer has finished, it will be delivered both to the website and to your email address so that you will not miss it. If your deadline is close at hand, we will place a call to you to make sure that you receive the paper on time.
Completing the order and download