2. Team Datawesome |Project
1
1. Requirements Analysis
1.1 Prior Situation
Excel Mechanical,Inc.isa PlumbingandCommercialHVACcontractingcompanythatwasestablishedin
Tucson,in 1990. Team DataWESOME workedwithExcel Mechanical tocreate a cost estimationsoftware
whichdigitizesthe company’scostestimationprocesses.
Priorto thisproject,Excel Mechanical usedaMicrosoft Excel sheettomanage costestimationforits
HVACand Plumbingservices.Due tothe complex nature of how costfactorscan be keyedintothe Excel
sheet,the employeesusedmanual waystocalculate service costs.Thisledtomanual errorincost
estimationandinefficientdatamanagementwhichposedhasslessuchasinabilitytoidentifyerrorsin
cost estimationanddifficultyintrackingpastclientcosts.
1.2 Business Requirements
Excel Mechanical,Inc.offerscustomizedservicestoitscustomers.Hence costinghastobe done
separatelyforeveryinquirybasedonthe requirements.
Thisprojectdigitizesthe costingfortwotypesof services:
1. HVAC (HeatingVentilation/AirConditioning)
2. Plumbing
A customercan place an enquiryforeitherHVACservicesorPlumbingservices.Costingof projectfor
bothHVACand plumbingdependson
a. Cost of RentedEquipmentforthe project
b. Labor cost of the teamwhichcomprisesof
i.Zero or One Engineer(s)
ii. SubContractedemployees(between0- 10) dependingonthe project
iii.Otheremployees(ForSpecial requirements)
Rentedequipmentare of manytypes.One ormore than one equipmentcanbe selectedforaproject.
Fewprojectsmaynot require anyequipment. Costof rentedequipmentdependsuponthe type of
equipment,numberof equipmentandthe durationforwhichthe equipmenthasbeenrented.
Labor Cost dependsonthe costof engineer,costof subcontractedemployeesandcostof other
employees.HVACmaintainsalistof engineersinitsdatabase.Eachengineerhasa differenthourlyrate.
3. Team Datawesome |Project
2
Cost of engineerdependsuponthe hourlyrate of the engineerselectedandthe numberof working
hours.
A projectmayor maynot require subcontractors.The hourlyrate of subcontractorsdependsonthe
type of work forwhichtheyhave beenhired.The costfor subcontractorsdependsonthe numberof
people hired,type of workandnumberof workinghourshiredfor.
There needstobe a facilitytohire otheremployeesasa part of the teamwithcustomhourlyrate and
numberof hoursfor the specificproject.
1.2.1 HVAC Services
CostingforHVACservicesdependsonthe costof specificserviceswhichvariesforeachinquiry.HVAC
cost dependsonthe costfor AC Equipment,Ductwork,Crane,GSM,Distributiontype.
Cost of AC equipmentdependsonthe followingcharacteristicselectrical,quantities,size(tonnage),
accessories,t-statandCO2. The cost for eachof these characteristicsdependsonthe familytowhichit
belongsto. ACequipmentcanbelongtoone of the followingfamilies:
Package,Split,Ductless,Chiller,CoolingTower,Evaporative,Cooler,andExhaustFans.
Cost of ductworkdependsonthe type andlengthof ductwork.Ductworkcan be of square,spiral orflex
type. A single projectmayuse one or all three typesof ductwork.
1. Cost of square ductwork dependsonthe sizesof ductworkused,R-Value of the
Ductwork,cost of fittings.Costof fittingsdependsonthe type of fittingsusedand
quantity.Italsodepends whetheritisa linedorwrappedductwork.
2. Cost of spiral ductworkdependsonthe sizesof ductworkused,R-Valueof the
ductwork,costof fittings.Costof fittingsdependsonthe type of fittingsusedand
quantity.Italsodependswhetheritisan exposedorwrappedductwork.
3. Cost of flex ductworkdependsonthe sizesof ductworkused,lengthof ductworkandcostof
miscellaneousthingswhichcaninclude one ormore of the following:straps,hangers,tape andspine.
Cost of miscellaneousthings dependsonthe numberof thingsusedforeachtype andthe price of each
unit.
4. Team Datawesome |Project
3
Cranescan eitherbe usedor notfor a particularproject.Costof crane dependsonsize of crane,price
perhour and the numberof hoursit has beenhiredfor.
Distributioncanhave one orall of:Airdevices,VavsorRelief Hoods.
Cost of Airdevicesdependsonsize andquantitiesof collarsandboxes.Costof a collaror a box depends
on size andthe quantitiesrequired.There canbe multiple collarsandboxesthatcanbe usedinan air
device.
Cost of Vavsdependsonthe sizesandquantitiesof hangersandconnectionsused.Costof ahangeror a
connectiondependsonthe size andquantitiesused.There canbe multiple hangersandconnections
that can be usedin a vav.
Cost of Relief Hoodsdependsonsizesandquantitiesof curbused.The costof a particularcurb depends
on the size andquantity.There canbe multiple curbsusedinarelief hood.
GSM can be usedor not usedfor a particularproject.Costof GSM dependsonthe cost of Cap flashing,
regletandothercosts.
Rental equipmentof type scissorlift,forklift,manliftandothercanbe usedforHVAC.One or all the
equipmentcanbe used.Costof equipmentdependsonhourlyrate whichdependsontype,the time for
whichithas beenrentedandthe numberof equipmentrented.Subcontractorsof the type controls,test
and balance andgas detectionare usedforHVAC.Costdependsonthe hourlyrate of the sub-contractor
whichdependsontype.Italsodependsonthe numberof contractorsand time forwhichtheyhave
beenhiredfor.
1.2.2 Plumbing Services
Cost of plumbingdependsonthe type of fitting,the size of fittingandthe quantitieswhichare required
for differentparts.The costof a particularfittingdepends ontype andsize.There are followingtypesof
parts: fixtures,coldwater,hotwater,condensate,waste vent(sewer),roof drain(same assewer),
compressedair,gas,medgas.
Subcontractorsof the followingtypescanbe usedforplumbingservices:sterilization,excavation,crane
and concrete.Subcontractorsof one or all the servicescanbe used.Costdependsonrate perhour,
numberof itemsandtime for whichtheyhave beenhired.
In Rentalsthe followingequipmentcanbe rented - mini-ex,back-hoe, scissorlift,forklift,other.Cost
dependsonrate perhour, numberhiredandtime forwhichithas beenhired.
5. Team Datawesome |Project
4
2. Conceptual Schema
2.1 Revised conceptual schema
CUSTOMER
HVAC_ENQUIRY
PLUMBING_ENQUIRY
Has
FEATURES
size
type
feature_ID
feature_Name
[1:M]
SUBCONTRACTORS OTHER_WORKERS
Comprises_AC
[1:1]
RENTAL_EQUIPMEN
TS
[0:M]
CRANE
DUCTWORK
ACCESSORIES
DISTRIBUTION
AC_EQUIPMENT
[1:1]
[1:1]
[1:1] [1:1]
P
SPIRALSQUARE FLEX
P
VAVS
AIR DEVICES
Contact_Number
first_Name
middle_Name
last_Name
addressrate
contact_Number
street
city
zip
name
rate
rental_ID
re_Name
rental_Rate
ac_equipment_
ID
equipment
_Type
subcontractor
_ID
worker_ID
ductwork_ID
isLined isWrapped isLined isWrapped
crane_ID
price size
time
distribution_IDaccessories_id
Accessories
_name
category
Enquiry_Cost
price
price
customer_ID
ENQUIRY
Places
[1:1]
[0:M]
P
Rent
[1:1]
Work[0:M] [0:M]Subcontract [0:M][0:M]
plan
construction_
Type
date
totalEnquiry
Cost
enquiryType
Rental_Fre
quency
enquiryID
fittings
price
name
address
customerName
ENGINEERS
Engineer
[0:1]
name
Engineer_ID
address
rate
contact_Number
sizes
price
sizes
electrical
Distribution_
Type
R_Value
sizes
price
RENTAL_DETAILS
value cost
COMPRISES_AC_EQUIPMENT
[1:1]
[1:1] quantitycost
Comprises_duct
[1:1]
COMPRISES_DUCTWORK
linearFo
otage
[1:1]
cost
Comprises_cr
[1:1]
[1:1]
COMPRISES_CRANE
cost
cost time
Comprises_acc
[0:M]
[0:M]
Comprises_duct
[1:1]
COMPRISES_DISTRIBUTION
[1:1]
quantitycost
state
R_Value
6. Team Datawesome |Project
5
2.2 Revised Data Dictionary
Data Dictionary (Conceptual for ER Modeling)
Schema Construct Construct Description Other Information
AC EQUIPMENT EntityClass,to model ACEquipment
information
· AC EQUIPMENT ID Identifyingidof the ACequipment IdentifyingAttribute
· ELECTRICAL Electrical ACEquipment
· EQUIPMENT TYPE Equipmenttype of the ACEquipment
· PRICE Price of AC Equipment
· SIZES(TONAGE) Sizesof ACEquipment
AC FAMILY EntityClass,to model ACFamily
Information
· AC ID ID of the ACtype IdentifyingAttribute
· AC NAME Name of the ACtype
AC ORDER EntityClass,to model ACOrder
information
· AC ORDER ID Identifyingnumberof the ACOrder IdentifyingAttribute
· AC ORDER COST Cost of the AC Order
7. Team Datawesome |Project
6
AIR DEVICES EntityClass,to model AirDevices
· PRICE Price of the AirDevices
· SIZES Collarsof AirDevices
CRANE EntityClass,to model Crane
· CRANEID Identifyingnumberof Crane IdentifyingAttribute
· PRICE Price of the Cranes
· SIZE Sizesof the Cranes
· TIME Time of the Cranes
CUSTOMERS EntityClass,to model Customer
information
· ADDRESS Addressof the Customer Composite attribute :
Street,City,State
· CONTACTNO Contact of the Customer Multi-valuedattribute
· CUSTOMER ID Identifyingnumberof the Customer IdentifyingAttribute
· CUSTOMER NAME Name of the Customer Composite - first,
middle,last
DISTRIBUTION EntityClass,to model Distribution
· DISTRIBUTION ID Identifyingnumberof Distribution IdentifyingAttribute
· DISTRIBUTION
TYPE
Type of Distribution
DUCTWORK EntityClass,to model Ductwork
information
· DUCTWORK ID Identifyingnumberof Ductwork IdentifyingAttribute
· PRICE Price of the Ductwork
8. Team Datawesome |Project
7
· SIZE Sizesof the Ductwork
· LINEARFOOTAGE Linearlengthof the Ductwork
ENGINEER EntityClass,to model Engineer
information
· ADDRESS Addressof the Engineer
· CONTACTNO Contact numberof the Engineer
· ENGINEER ID Identifyingnumberof the Engineer IdentifyingAttribute
· NAME Name of the Engineer
· RATE Hourlyrate of the Engineer
FEATURES EntityClass,to model Features
information
· FEATURE ID Id of the Feature/Fittings IdentifyingAttribute
· FEATURE NAME Name of the Fittings
· PRICE Price of the Fittings
· SIZE Size of the Fittings
· TYPE Type of the Fittings
· FITTINGS Fittingsused
FLEX EntityClass,to model Flex Ductwork
· R VALUE R-Value of Flex Ductwork
HVAC COST
BREAKDOWN
EntityClass,to model HVACCOST
BREAKDOWN Information
· TOTAL COST Total costfor the HVACcontract
9. Team Datawesome |Project
8
HVAC ENQUIRY EntityClass,to model HVACEnquiry
information
· CONSTRUCTION
TYPE
Contructiontype of HVAC
· DATE Date of the HVACEnquiry
· ENQUIRY ID Identifyingnumberof the HVACEnquiry IdentifyingAttribute
· PLAN Planof the HVAC
· ENQUIRY TYPE Type of HAVCEnquiry
OTHER WORKERS EntityClass,to model OtherWorkers
information
· NAME Name of Workers
· RATE Rate forWorkers
· WORKER ID Identifyingnumberof the Worker IdentifyingAttribute
PLUMBING COST
BREAKDOWN
EntityClass,to model PLUMBINGCOST
BREAKDOWN Information
· TOTAL COST Total costfor the PlumbingContract
PLUMBING
ENQUIRY
EntityClass,to model PlumbingEnquiry
information
· CONSTRUCTION
TYPE
Constructiontype of Plumbing
· DATE Date of the PlumbingEnquiry
· ENQUIRY ID Identifyingnumberof the Plumbing
Enquiry
IdentifyingAttribute
· PLAN Planof the Plumbing
RENTAL
EQUIPMENTS
EntityClass,to model Teaminformation
10. Team Datawesome |Project
9
· RENTAL
EQUIPMENT NAME
Name of the Rental Equipment
· RENTAL ID Identifyingnumberof the Rental IdentifyingAttribute
· RENTAL RATE The rental rate for the equipment
· CATEGORY Categoryof the rental equipment - HVAC
or Plumbing
· RENTAL
FREQUENCY
Frequencywithwhichthe Equipmentis
Rented
SPIRAL EntityClass,to model Spiral Ductwork
· IS LINED Booleanvalue of whetherDuctworkis
lined
· IS WRAPPED Booleanvalue of whetherDuctworkis
wrapped
SQUARE EntityClass,to model Square information
· IS LINED Booleanvalue of whetherDuctworkis
lined
· IS WRAPPED Booleanvalue of whetherDuctworkis
wrapped
SUBCONTRACTOR EntityClass,to model Subcontractor
information
· CONTACTNO Contact numberof the Subcontractor
· NAME Name of the Subcontractor
· RATE Hourlyrate of the Subcontractor
· SUBCONTRACTOR
ID
Identifyingnumberof the Subcontractor IdentifyingAttribute
VAVS EntityClass,to model Vavs
11. Team Datawesome |Project
10
· PRICE Price of the Vavs
· SIZES Sizesof Vavs
3. Normalized Relational Schema
3.1 Relational Schema
The belowtableshave were derivedafterERdiagram to Relational Scheme conversion.
CUSTOMERS ( customer_ID,street,city,state,zip,firstName,middleName,lastName)
CUST_PHONES (customer_ID,contact_number)
Foreignkey(customer_ID) referencesCUSTOMERS
ENQUIRY ( enquiryID,enquiryType,plan,date,totalEnquiryCost,constructionType,engineerID)
Foreignkey(engineerID) referencesENGINEERS
SUBCONTRACTORS (subcontractor_ID,rate,name,address)
SUBCONTRACT (enquiryID,subcontractor_ID)
Foreignkey(enquiryID) referencesENQUIRY
Foreignkey(subcontractor_ID) referencesSUBCONTRACTORS
SUBCONT_PHONE (subcontractor_ID,contactnum)
Foreignkey(subcontractor_ID) referencesSUBCONTRACTORS
ENGINEERS (engineerID,rate,name,address)
ENG_PHONE (engineerID,contactnum)
Foreignkey(engineerID)referencesENGINEERS
13. Team Datawesome |Project
12
FLEX (ductwork_ID,rvalue )
Foreignkey(ductwork_ID) referencesDUCTWORK
CRANE (crane_ID,price,size ,time)
COMPRISE_CRANE (enquiryID,crane_ID,cost,time)
Foreignkey(enquiryID) referencesHVAC_ENQUIRY
Foreignkey(crane_ID) referencesCRANE
DISTRIBUTION (distribution_ID,type,size,price )
COMPRISE_DISTRIBUTION (enquiryID,Distribution_ID,cost,quantity)
Foreignkey(enquiryID) referencesHVAC_ENQUIRY
Foreignkey(distribution_ID) referencesDISTRIBUTION
PLUMBING_ENQUIRY (enquiryID)
Foreignkey (enquiryID) referencesENQUIRY
FEATURES ( feature_ID,name,size,price,type,fittings)
PLUM_FEATURES (enquiryID,feature_ID)
Foreignkey(enquiryID) referencesPLUMBING_ENQUIRY
Foreignkey(feature_ID) referencesFEATURES
All the above mentionedrelationsare normalizedto4NFand noseparate conversionwasrequired.
However,some importantpointstonote duringthe conversionof ERdiagramto relational model is
OptionC wasusedto convertthe entityDISTRIBUTION .The 2 mainreasonsforusingOption Cinstead
of the standardOptionA is
i. The subclassesAirDevicesandVavsdonothave any attribute of theirown.
ii. The subclassesdonothave any otherrelationbesidesDISTRIBUTION.
Anotherthingwhichcanbe notedisall the weakentityclassesusedtostore Costhave enquiry_IDas
theirprimarykeywhichhelpsineasyCostestimation.
14. Team Datawesome |Project
13
3.2 Data Dictionary
Data Dictionary ( Relational )
Schema Construct Data type Constraint
AC _EQUIPMENT EntityClass,
to model AC
Equipment
information
· AC EQUIPMENT ID Int (3) PRIMARY KEY
· EQUIPMENT TYPE Varchar (50)
· PRICE Decimal (7,2)
· SIZES(TONAGE)
AC_EQUIPMENT ELECTRICAL Entityclassto
modele AC
Equipment
electrical
information
·ACEQUIPMENTELECTRICAL
ID
Int (3) PRIMARY KEY
· AC EQUIPMENT ID Int (3) ForeignkeyreferencesAC_EQUIPMENT
· ELECTRICAL Varchar (50)
AC EQUIPMENT SIZES
· AC EQUIPMENT SIZES ID Int (3) PRIMARY KEY
· AC EQUIPMENT ID Int (3) ForeignkeyreferencesAC_EQUIPMENT
15. Team Datawesome |Project
14
· SIZES Decimal (7,2)
COMPRISES_AC_EQUIPMENT EntityClass,
to model
weakentity
class
· ACEQUIPMENT ELECTRICAL
ID
Int (3) PRIMARY KEY, FOREIGN KEY REFERENCES
AC_EQUIPMENT ELECTRICAL
· AC EQUIPMENT ID Int (3) PRIMARY KEY, FOREIGN KEY REFERENCES
AC _EQUIPMENT
· AC EQUIPMENT SIZES ID Int (3) PRIMARY KEY, FOREIGN KEY REFERENCES
AC _EQUIPMENT
· AC EQUIPMENT QUANTITY Int (3)
· COST Decimal(7,2)
· ENQUIRY ID Int (5) PRIMARY KEY
COMPRISES_ACCESSORIES EntityClass,
to model
weakentity
class
· AC EQUIPMENT ID Int (3) PRIMARY KEY, FOREIGN KEY REFERENCES
HVAC_ENQUIRY
· ENQUIRY ID Int (5) PRIMARY KEY, FOREIGN KEY REFERENCES
HVAC_ENQUIRY
COMPRISES_CRANE EntityClass,
to model
weakentity
class
16. Team Datawesome |Project
15
· COST Decimal(7,2)
· CRANEID Int (3) PRIMARY KEY, FOREIGN KEY REFERENCES
CRANE
· CRANETIME Decimal(6,2)
· ENQUIRY ID Int (5) PRIMARY KEY, FOREIGN KEY REFERENCES
HVAC_ENQUIRY
COMPRISES_DISTRIBUTION EntityClass,
to model
weakentity
class
· COST Decimal(7,2)
· DISTRIBUTION ID Int (3) PRIMARY KEY, FOREIGN KEY REFERENCES
DISTRIBUTION
· ENQUIRY ID Int (5) PRIMARY KEY, FOREIGN KEY REFERENCES
HVAC_ENQUIRY
· QUANTITY Int (3)
COMPRISES_DUCTWORK EntityClass,
to model
weakentity
class
· COST Decimal(7,2)
· DUCTWORK ID Int (3) PRIMARY KEY, FOREIGN KEY REFERENCES
DUCTWORK
· ENQUIRY ID Int (5) PRIMARY KEY, FOREIGN KEY REFERENCES
HVAC_ENQUIRY
· LINEARFOOTAGE Decimal(6,2)
· RVALUE (4,2)
17. Team Datawesome |Project
16
CRANE EntityClass,
to model
Crane
· CRANEID Int (3) PRIMARY KEY
· PRICE Decimal (7,2)
· SIZE Int (3)
CUSTOMERS EntityClass,
to model
Customer
information
· ADDSTATE Varchar(50)
· CITY Varchar(50)
· CONTACTNO
· CUSTOMER ID Int (3) PRIMARY KEY
· FIRSTNAME Varchar(50)
· LASTNAME Varchar(50)
· MIDDLENAME Varchar(50)
· STREET Varchar(50)
· ZIP Int (3)
CUSTOMER
CONTACTNUMBER
EntityClass,
to model
Customer
· CUSTOMER ID Int (3) PRIMARY KEY,
FOREIGN KEY REFERENCESCUSTOMERS
·CUSTOMERCONTACT
NUMBER
Varchar(10) PRIMARY KEY
18. Team Datawesome |Project
17
DUCTWORK EntityClass,
to model
Ductwork
information
· DUCTWORK ID Int(3) PRIMARY KEY
· PRICE Decimal(7,2)
· SIZE Varchar(50)
· DUCTWORK TYPE Varchar(50)
ENGINEER EntityClass,
to model
Engineer
information
· ADDRESS Varchar(50)
· ENGINEER ID Int(3) PRIMARY KEY
· NAME Varchar(50)
· RATE Decimal(7,2)
ENGINEER
CONTACTNUMBER
EntityClass,
to model
Engineer
contact
number
·CUSTOMERCONTACT
NUMBER
Varchar(10) PRIMARY KEY
· ENGINEER ID Int (3) PRIMARY KEY,
FOREIGN KEY REFERENCESENGINEER
19. Team Datawesome |Project
18
ENQUIRY EntityClass,
to model
Enquiry
· CUSTOMER ID Int(3) FOREIGN KEY REFERENCESCUSTOMER
· CONSTRUCTION TYPE Varchar(50)
· ENGINEER ID Int(3) FOREIGN KEY REFERENCESENGINEERS
· ENQUIRY DATE Date
· ENQUIRY ID Int(5) PRIMARY KEY
· ENQUIRY TYPE Varchar(50)
· PLAN Varchar(50)
· TOTAL ENQUIRY COST Decimal(7,2)
· USER ID Int(11) FOREIGN KEYREFERENCES REGISTER
FEATURES EntityClass,
to model
Features
information
· FEATURE ID Int(3) PRIMARY KEY
· FEATURE NAME Varchar(50)
· PRICE Decimal(7,2)
· SIZE Decimal(6,2)
· TYPE Varchar(50)
· FITTINGS Varchar(50)
FLEX EntityClass,
to model Flex
Ductwork
· DUCTWORK ID Int(3) FOREIGN KEY REFERENCESDUCTWORK ,
20. Team Datawesome |Project
19
PRIMARY KEY
· R VALUE Decimal(4,2)
HVAC ENQUIRY EntityClass,
to model
HVACEnquiry
information
· ENQUIRY ID Int(5) PRIMARY KEY,
FOREIGN KEY REFERENCESENQUIRY
· ENQUIRY COST Decimal(7,2)
OTHER WORKERS EntityClass,
to model
Other
Workers
information
· NAME Varchar(50)
· RATE Decimal(7,2)
· WORKER ID Int(3) PRIMARY KEY
PLUMBING ENQUIRY EntityClass,
to model
Plumbing
Enquiry
information
· ENQUIRY ID Int(5) PRIMARY KEY,
FOREIGN KEY REFERENCESENQUIRY
PLUM FEATURES EntityClass,
to model
21. Team Datawesome |Project
20
Plumbing
Features
information
· ENQUIRY ID Int(5) PRIMARY KEY,
FOREIGN KEY REFERENCES
PLUMBING_ENQUIRY
· FEATURE ID Int(3) PRIMARY KEY,
FOREIGN KEY REFERENCESFEATURES
RENTAL DETAILS EntityClass,
to model
Rental details
information
· COST Decimal(7,2)
· ENQUIRY ID Int(5) PRIMARY KEY,
FOREIGN KEY REFERENCESRENTAL
EQUIPMENTS
· RENTAL ID Int(3) PRIMARY KEY
· RENTAL VALUE Int(3)
RENTAL EQUIPMENTS EntityClass,
to model
Rental
Equipments
information
· RENTAL NAME Varchar(50)
· RENTAL ID Int(3) PRIMARY KEY
· RENTAL RATE Decimal(7,2)
· CATEGORY Varchar(60)
· RENTAL FREQUENCY Varchar(50)
22. Team Datawesome |Project
21
SPIRAL EntityClass,
to model
Spiral
Ductwork
· DUCTWORK ID Int(3) FOREIGN KEY REFERENCESDUCTWORK ,
PRIMARY KEY
· IS LINED Char(1)
· IS WRAPPED Char(1)
SQUARE EntityClass,
to model
Square
information
· DUCTWORK ID Int(3) FOREIGN KEY REFERENCES DUCTWORK ,
PRIMARY KEY
· IS LINED Char(1)
· IS WRAPPED Char(1)
SUBCONTRACTOR EntityClass,
to model
Subcontractor
information
· ADDRESS Varchar(50)
· NAME Varchar(50)
· RATE Decimal(7,2)
· SUBCONTRACTORID Int(3) PRIMARY KEY
SUBCONTRACTOR
CONTACTNUMBER
EntityClass,
to model
Subcontractor
contact
23. Team Datawesome |Project
22
number
information
· SUBCONTRACTORID Int (3) PRIMARY KEY,
FOREIGN KEY REFERENCES
SUBCONTRACTOR
· SUBCONTRACTORCONTACT
NUMBER
Varchar(10) PRIMARY KEY
3.3 Appendix to Chapter 3:
The appendix tochapter3 comprisesof SQLstatementstocreate tablesandthe Procedures.We didnot
use any Triggersinour project.The appendix isavailable atthe endof the report.
4. Data Population and Queries
Excel Mechanical Inc.has a lot of data storedinExcel sheets.Thisdatamainlycomprisesof the different
equipment,ductwork,distributionandthe price relatedtoeachone of themwithrespecttodifferent
sizes,electrical andR-Value.Since the actual datawastoo dauntingtobe enteredintothe tables,we
decidedtocreate queriestoinserttestdata.The tableswere createdkeepinginmindall the possible
data that the clientneedsandwill needinthe future butonlyfew datahasbeenenteredforthe interest
of thisproject.
25. Team Datawesome |Project
24
subclasses,we see thatthe differentsubclasstypesare enteredinthe respective tablesandthere isno
overlap.Thisenabledustohandle the superclass-subclassscenariowithoutanyredundancyof data.
Query2:
SELECT e.ENQUIRY_ID,r.name asUSER_NAME ,concat(c.first_name,'',c.middle_name,'',c.last_name) as
CUSTOMER_NAME, e.ENQUIRY_DATE,e.ENQUIRYTYPE,e.PLAN,e.CONSTRUCTION_TYPE,
concat('$',e.totalEnquiryCost) asTotal_Enquiry_Cost
fromENQUIRY e, REGISTER r, CUSTOMER c
where e.user_id=r.uid
ANDe.customer_id=c.customer_id
orderby e.enquiry_id;
The above querygeneratesthe masterreportonthe home page.Thisreportbasicallydisplaysthe
detailsof everyenquirythathasbeendone inthe system.Inorderto getthe detailsof anEnquiry,the
tablesENQUIRY,REGISTER andCUSTOMER have beenjoinedonthe foreignkeysthatare presentinthe
ENQUIRY table.The totalEnquiryCostattribute isformattedtoincludea$ signinfrontof the numeric
data. Finally,the resultsare sortedbasedonthe EnquiryID to displayinachronological order.
Query3:
SELECT * FROM
(
SELECT r.uidas USER_ID,
CASE WHEN enquiry_date=DATE(sysdate())THEN 'TODAY' END ASFREQUENCY
,sum(totalEnquiryCost) ASTOTAL_ENQUIRY_COST,count(ENQUIRY_ID) ASNO_OF_ENQUIRY
fromENQUIRY e, REGISTER r
where e.user_id=r.uid
and enquiry_date=DATE(sysdate())
GROUP BY r.uid,FREQUENCY
UNION
SELECT r.uidas USER_ID,
CASE WHEN enquiry_date BETWEEN DATE_SUB(NOW(),INTERVAL7 DAY) ANDNOW()
THEN 'WEEKLY' END AS FREQUENCY
,sum(totalEnquiryCost) ASTOTAL_ENQUIRY_COST,count(ENQUIRY_ID) ASNO_OF_ENQUIRY
fromENQUIRY e, REGISTER r
where e.user_id=r.uid
and enquiry_date BETWEEN DATE_SUB(NOW(),INTERVAL7 DAY) ANDNOW()
GROUP BY r.uid,FREQUENCY
UNION
SELECT r.uidas USER_ID,
CASE WHEN enquiry_date BETWEEN DATE_SUB(NOW(),INTERVAL30 DAY) ANDNOW()
26. Team Datawesome |Project
25
THEN 'MONTHLY' END AS FREQUENCY
,sum(totalEnquiryCost) ASTOTAL_ENQUIRY_COST,count(ENQUIRY_ID) ASNO_OF_ENQUIRY
fromENQUIRY e, REGISTER r
where e.user_id=r.uid
and enquiry_date BETWEEN DATE_SUB(NOW(),INTERVAL30 DAY) ANDNOW()
GROUP BY r.uid,FREQUENCY
) A
ORDER BY USER_ID,FREQUENCY;
The above querygeneratesareportfor the administratorwhocanview the numberof enquiriesandthe
total cost associatedwithall of themandsegregate itbasedona daily,weeklyandmonthlybasisfor
each user.The queryseparatelyfindsthe daily,weeklyandmonthlyentriesandthenisdisplayed
togetherusinganUNION operator.Let usconsiderthe firstsegmentwhere the dailyenquiriesare
calculated.A CASEstatementisusedtoset the Frequencyfieldtobe displayedandif the sysdate
matchesthe enquirydate,thenthe frequencyisDaily.A similarlogic isusedtoseparate all suchrecords
and thenSUM and COUNTfunctionsare usedto findthe cost of all the enquiriesandtotal numberof
enquiriesrespectively.Thislogicisfollowedinthe nexttwosegmentswithonlyfrequencybeing
different.If the interval betweensysdateandenquirydate is7days, the frequencyisweeklywhereasif
it is30 days,the frequencyismonthly.Eachsegmentisgroupedbyuseridand frequencyandafterthe
UNION is performed,the whole queryissortedbasedonuseridand frequency.
Query4:
SELECT EXTRACT(YEARFROMenquiry_date)ASENQUIRY_YEAR,
CASE
WHEN EXTRACT(MONTHFROM enquiry_date) =01 THEN 'JAN'
WHEN EXTRACT(MONTHFROM enquiry_date) =02 THEN 'FEB'
WHEN EXTRACT(MONTHFROM enquiry_date) =03 THEN 'MAR'
WHEN EXTRACT(MONTHFROM enquiry_date) =04 THEN 'APR'
WHEN EXTRACT(MONTHFROM enquiry_date) =05 THEN 'MAY'
WHEN EXTRACT(MONTHFROM enquiry_date) =06 THEN 'JUN'
WHEN EXTRACT(MONTHFROM enquiry_date) =07 THEN 'JUL'
WHEN EXTRACT(MONTHFROM enquiry_date) =08 THEN 'AUG'
WHEN EXTRACT(MONTHFROM enquiry_date) =09 THEN 'SEP'
WHEN EXTRACT(MONTHFROM enquiry_date) =10 THEN 'OCT'
WHEN EXTRACT(MONTHFROM enquiry_date) =11 THEN 'NOV'
WHEN EXTRACT(MONTHFROM enquiry_date) =12 THEN 'DEC'
END AS ENQUIRY_MONTH,
COUNT(ENQUIRY_ID) ASNO_OF_ENQUIRY,
CONCAT('$',SUM(totalEnquiryCost)) ASTOTAL_ENQUIRY_COST
FROMENQUIRY E
27. Team Datawesome |Project
26
GROUP BY ENQUIRY_YEAR,ENQUIRY_MONTH
ORDER BY FIELD( ENQUIRY_MONTH,
'JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC');
Thisqueryalso generatesanadministrativereportbutthisdisplaysthe numberof enquiriesandthe
total cost associatedwithitforeverymonth.The queryusesthe CASEstatementtoextractthe month
fromthe enquirydate andsetthe monthname.The SUM and COUNT functionsare usedtofindthe cost
of all the enquiriesandtotal numberof enquiriesrespectively.The sumisformattedandthe outputis
groupedbasedonyearand month.For UI aesthetics,the recordsare alsosortedand thendisplayed.
As perour projectrequirements,mostof ourquerieshave beenwrittenwithinprocedures,whosemain
aimis to insertdataintothe database basedonuser’schoice onthe Enquiryform.Everysectionhasa
correspondingprocedure whichiscalled,everytime auserentersandsubmitsanenquiry.The following
queriesare snippetsfromthose proceduresandthoughthe queryexplanationisprovidedinthis
section,the procedureswill be explainedinabroaderfashioninChapter5.
Query5:
INSERT INTOENQUIRY (ENQUIRY_DATE,enquiryType) VALUES(DATE(SYSDATE()),'HVAC');
The above queryisa simple querytoinsertthe enquirydate andenquirytype intothe ENQUIRYtable
but the logicbehinditisquite innovative.Inordertohandle concurrency,we hadto reserve aparticular
enquiryidforeachsession,sothatanotheruserdoesnot start usingthe same enquiryid.The enquiryid
isan auto incrementedprimarykeyfieldandthuseverytime auserstarts creatingan enquiry,the
systeminsertsarecordwithonlythe date andtype.The DB createsan enquiryidusingthe auto
incrementfunctionandthisenquiryidgetsstoredandusedforall the followinginstructionsforthe
particularuser.
Query6:
SELECT coalesce(sum(cost),0) INTOv_cost1FROMCOMPRISES_AC_EQUIPMENT where ENQUIRY_ID=
v_enquiry_id;
SELECT coalesce(sum(cost),0) INTOv_cost2FROMCOMPRISES_CRANE where ENQUIRY_ID=
v_enquiry_id;
SELECT coalesce(sum(cost),0) INTOv_cost3FROMCOMPRISES_DISTRIBUTION where ENQUIRY_ID=
v_enquiry_id;
SELECT coalesce(sum(cost),0) INTOv_cost4FROMCOMPRISES_DUCTWORK where ENQUIRY_ID=
v_enquiry_id;
28. Team Datawesome |Project
27
The above querysnippetisalsofroma procedure whichcalculatesall the costfromthe weakentity
classesandis addedtoget a final costin the maintable.We foundthat if a user was not enteringa
value fora particularfield,the costwasreturningnull.If asingle value wasalsonull,the total costwas
comingnull.Thatis whythe coalesce functionwasintroducedtohandle anynull casesandconverting
themto zeroso that there are no null valueswhilecalculatingthe sum.
As perour projectrequirements,we have 10proceduresandfewerSQLqueries.Majorfunctionalities
have beenrealizedthroughproceduresandwhichwill be explainedinthe nextchapter.
5. Triggers and Procedures
As part of thisprojecteffort,we have createdtendifferentProcedurestoeitheraddor update the
attributesindifferentcolumns.
Note:Since ourclientrequestedaworkable productwhichwouldnotcostanythingtothem, we had
decidedtouse MySQL database insteadof Oracle.Sothe followingquerieswill be followingMySQL
syntax.
Procedure 1:
To create newenquiryidinENQUIRY table,new ac_order_idinAC_ORDERtable and alsocorresponding
row inHVAC_ENQUIRYtable
DELIMITER //
CREATE PROCEDURE PROC_ENQUIRY_ID(IN in_user_idInt(11))
BEGIN
DECLARE v_enquiry_idINT(5);
INSERTINTO ENQUIRY (ENQUIRY_DATE,enquiryType,user_id) VALUES(DATE(SYSDATE()
),'HVAC',in_user_id);
SELECT MAX(ENQUIRY_ID) INTOv_enquiry_idfromENQUIRY;
INSERTINTO HVAC_ENQUIRY(ENQUIRY_ID,ENQUIRY_COST) VALUES (v_enquiry_id,0);
END;
//
In thisProcedure,wheneverausertriesto create an enquiry,currentdate,enquirytype andthe userid
associatedwiththatUser isinsertedintoENQUIRYtable.Atthe same time EnquiryIDcorrespondingto
the earlierenquiryisinsertedintothe HVAC_ENQUIRYtable andEnquiryCostissetto ‘0’.
29. Team Datawesome |Project
28
Procedure 2:
Procedure toupdate Plan,Engineer,Construction_Type andcustomer_idinENQUIRY
DELIMITER //
CREATE PROCEDURE PROC_ENQUIRY_PLAN (IN v_enquiry_idInt(5),IN in_customer_idInt(3),IN in_plan
VARCHAR(50),
IN in_engineer_idINT(3),IN in_construction_type VARCHAR(50))
BEGIN
UPDATE ENQUIRY
SET PLAN = in_plan,ENGINEER_ID = in_engineer_id,CONSTRUCTION_TYPE=
in_construction_type,customer_ID=in_customer_id
WHERE ENQUIRY_ID = v_enquiry_id;
END;
//
In thisProcedure,we take five inputparametersfromthe UI.We update the ENQUIRY table whichthe
detailsprovidedinthe inputparametersi.e.Plan,EngineerID,Constructiontype andCustomerIDis
update forthe givenEnquiryID.
Procedure 3:
Procedure toinsertdata intoCOMPRISES_AC_EQUIPMENTTABLE
DELIMITER //
CREATE PROCEDURE PROC_COMPRISES_AC_EQUIPMENT(IN v_enquiry_idInt(5),IN
in_ac_equipment_idInt(3),
IN in_qtyInt(3),IN in_ac_equipment_electrical_idInt(3),in_ac_equipment_sizes_idInt(3))
BEGIN
DECLARE v_cost1 Decimal(7,2);
DECLARE v_cost2 Decimal(7,2);
SELECT price INTO v_cost1 FROMAC_EQUIPMENT WHERE ac_equipment_ID=
in_ac_equipment_id;
SET v_cost2 = v_cost1 * in_qty;
INSERTINTO COMPRISES_AC_EQUIPMENT
(ac_equipment_ID,enquiry_ID,ac_equipment_electrical_id,ac_equipment_sizes_id,ac_equipment_qty,c
ost)
VALUES
(in_ac_equipment_id,v_enquiry_id,in_ac_equipment_electrical_id,in_ac_equipment_sizes_id,in_qty,v_c
ost2);
END;
//
30. Team Datawesome |Project
29
In thisprocedure,we take five inputparametersfromthe UI.Firstwe get the cost associatedwiththe
givenACequipmentIDandthenlatermultipliedwiththe quantityprovidedtogetthe total cost of the
AC Equipment.This costislaterinsertedintothe weakclassCOMPRISES_AC_EQUIPMENTtable withthe
inputparametersof the procedure vizACequipmentID,EnquiryID,Ac Equipmentelectrical ID,AC
EquipmentSizesID,ACequipmentquantityandthe total cost calculated.
Procedure 4:
Procedure toinsertdata intoCOMPRISES_ACCESSORIESTABLE
DELIMITER //
CREATE PROCEDURE PROC_COMPRISES_ACCESSORIES(IN v_enquiry_idInt(5),IN in_accessories_id
Int(3))
BEGIN
INSERTINTO COMPRISES_ACCESSORIES(enquiry_id,accessories_id)
VALUES(v_enquiry_id,in_accessories_id);
END;
//
In thisprocedure,we take EnquiryIDand AccessoriesIDasthe inputparameter.We insertdatainto
COMPRISES_ACCESSORIEStable withthe valuesprovidedinthe input parameters.
Procedure 5:
Procedure toinsertdata intoCOMPRISES_DUCTWORKfor flex ductworktype
DELIMITER //
CREATE PROCEDURE PROC_COMPRISES_DUCTWORK_FLEX(IN v_enquiry_idInt(5),IN in_type
Varchar(50),IN in_size Varchar(50),
IN in_linearFootageDecimal(6,2),IN in_rval Decimal(4,2))
BEGIN
DECLARE v_ductwork_idINT(3);
DECLARE v_cost1 Decimal(7,2);
SELECT ductwork_idINTOv_ductwork_idFROMDUCTWORK
WHERE ductwork_type =in_type ANDsizes=in_size;
SELECT price INTO v_cost1 FROMDUCTWORK
WHERE ductwork_type =in_type ANDsizes=in_size;
INSERTINTO COMPRISES_DUCTWORK(enquiry_id,ductwork_id,linearFootage,rValue,cost)
VALUES(v_enquiry_id,v_ductwork_id,in_linearFootage,in_rval,v_cost1);
END;
31. Team Datawesome |Project
30
//
We have a procedure forFlex ductworkandone commonprocedure forsquare andspiral ductwork.The
reasonbeingsquare andspiral ductworkhave commonattributes.
In thisprocedure,we take five inputparameters.Firstwe findoutthe ductworkidassociatedwiththe
givenductworktype andsize.Laterthe price for the givenductworktype and size isfoundout.We then
insertthese valuesintoCOMPRISES_DUCTWORKtable.
Procedure 6:
Procedure toinsertdata intoCOMPRISES_DUCTWORKfor square andspiral ductworktype
DELIMITER //
CREATE PROCEDURE PROC_COMPRISES_DUCTWORK_SQUARESPIRAL(IN v_enquiry_idInt(5),IN in_type
Varchar(50),IN in_size Varchar(50),
IN in_linearFootageDecimal(6,2),IN in_insVarchar(50))
BEGIN
DECLARE v_ductwork_idINT(3);
DECLARE v_cost1 Decimal(7,2);
IF (in_type ='SPIRAL') THEN
IF (in_ins='Wrapped') THEN
SELECT d.ductwork_idINTOv_ductwork_idFROMDUCTWORK d JOIN SPIRALs
ON d.ductwork_ID=s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isWrapped=
'Y';
SELECT d.price INTOv_cost1 FROMDUCTWORK d JOIN SPIRALs ON
d.ductwork_ID= s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isWrapped=
'Y';
ELSEIF (in_ins='Lined') THEN
SELECT d.ductwork_idINTOv_ductwork_idFROMDUCTWORK d JOIN SPIRALs
ON d.ductwork_ID=s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isLined='Y';
SELECT d.price INTOv_cost1 FROMDUCTWORK d JOIN SPIRALs ON
d.ductwork_ID= s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isLined='Y';
END IF;
ELSEIF (in_type ='SQUARE') THEN
IF (in_ins='Wrapped') THEN
SELECT d.ductwork_idINTOv_ductwork_idFROMDUCTWORK d JOIN SQUARE
s ON d.ductwork_ID= s.ductwork_ID
32. Team Datawesome |Project
31
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isWrapped=
'Y';
SELECT d.price INTOv_cost1 FROMDUCTWORK d JOIN SQUARE s ON
d.ductwork_ID= s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isWrapped=
'Y';
ELSEIF (in_ins='Lined') THEN
SELECT d.ductwork_idINTOv_ductwork_idFROMDUCTWORK d JOIN SQUARE
s ON d.ductwork_ID= s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isLined='Y';
SELECT d.price INTOv_cost1 FROMDUCTWORK d JOIN SQUARE s ON
d.ductwork_ID= s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isLined='Y';
END IF;
END IF;
INSERTINTO COMPRISES_DUCTWORK(enquiry_id,ductwork_id,linearFootage,cost)
VALUES (v_enquiry_id,v_ductwork_id,in_linearFootage,v_cost1);
END;
//
Thisprocedure dealswith square andspiral ductwork.If else conditionalstatementisusedtofindthe
appropriate costassociate withthe givenductworktype,size dependinguponwhetheritis‘Wrapped’
or ‘Lined’.Laterthiscost alongwithEnquiryID,ductworkID and linearfootage isupdatedin
COMPRISES_DUCTWORKtable.
Procedure 7:
Procedure toinsertdata intoCOMPRISES_CRANE
DELIMITER //
CREATE PROCEDURE PROC_COMPRISES_CRANE(IN v_enquiry_idInt(5),IN in_crane_idInt(3),IN
in_time decimal (6,2))
BEGIN
DECLARE v_cost1 Decimal(7,2);
DECLARE v_cost2 Decimal(7,2);
SELECT price INTO v_cost1 FROMCRANEWHERE crane_id= in_crane_id;
SET v_cost2= v_cost1 * in_time;
INSERTINTO COMPRISES_CRANE(enquiry_id,crane_id,crane_time,cost)
VALUES(v_enquiry_id,in_crane_id,in_time,v_cost2);
END;
//
33. Team Datawesome |Project
32
In thisprocedure,we take enquiryID,crane IDand time as the inputparameters.We latercalculate the
total cost for the crane usage bymultiplyingbase costwiththe numberof hours/days/monthsused.
Thiscost is insertedintoCOMPRISES_CRANEtable alongwithEnquiryID,Crane IDand Crane time.
Procedure 8:
Procedure toinsertintoCOMPRISES_DISTRIBUTION
DELIMITER //
CREATE PROCEDURE PROC_COMPRISES_DISTRIBUTION (IN v_enquiry_idInt(5),IN in_distribution_id
Int(3),IN in_qtyInt(3))
BEGIN
DECLARE v_cost1 Decimal(7,2);
DECLARE v_cost2 Decimal(7,2);
SELECT price INTO v_cost1 FROMDISTRIBUTION WHERE distribution_ID=in_distribution_id;
SET v_cost2 = v_cost1 * in_qty;
INSERTINTO COMPRISES_DISTRIBUTION (enquiry_ID,distribution_ID,distribution_qty,cost)
VALUES(v_enquiry_id,in_distribution_id,in_qty,v_cost2);
END;
//
In thisprocedure,firstthe costforthe givendistributionIDisfoundout.Laterthe final costis calculated
dependingonthe quantitymentioned.Thisfinal costisinsertedintoCOMPRISES_DISTRIBUTIONtable
alongwithEnquiryID,distributionIDanddistributionquantity.
Procedure 9:
Procedure toinsertintoRENTAL_DETAILS
DELIMITER //
CREATE PROCEDURE PROC_RENTAL_DETAILS(IN v_enquiry_idInt(5),IN in_equipment_name VARCHAR
(60),IN in_rental_frequencyvarchar(50),IN in_rental_value INT(3))
BEGIN
DECLARE v_rental_idINT(5);
DECLARE v_cost1 Decimal(7,2);
DECLARE v_cost2 Decimal(7,2);
DECLARE v_name VARCHAR(100);
34. Team Datawesome |Project
33
SELECT RENTAL_IDINTO v_rental_idfromRENTAL_EQUIPMENTS
WHERE concat(rental_Name,'-',coalesce(category,'')) =in_equipment_name
ANDRental_Frequency=in_rental_frequency;
SELECT rental_Rate INTO v_cost1 FROMRENTAL_EQUIPMENTS WHERE rental_ID= v_rental_id;
SET v_cost2= v_cost1 * in_rental_value;
INSERTINTO RENTAL_DETAILS(enquiry_id,RENTAL_ID,rental_value,cost)
VALUES(v_enquiry_id,v_rental_id,in_rental_value,v_cost2);
END;
//
In thisprocedure,rental IDforthe givenrental equipmentname andrental frequencyisfound.Thenwe
findthe rental rate associatedwiththatrental ID. Finallythe costassociatedwiththe rental equipment
isthe productof rental rate and rental value.Thistotal costis insertedintoRENTAL_DETAILSalongwith
EnquiryID,Rental ID and rental value.
Procedure 10:
Calculate the value of Enquiry_CostinHVAC_ENQUIRY
DELIMITER //
CREATE PROCEDURE PROC_COST_AGGREGATION (IN v_enquiry_idInt(5))
BEGIN
DECLARE v_cost1 DECIMAL(7,2);
DECLARE v_cost2 DECIMAL(7,2);
DECLARE v_cost3 DECIMAL(7,2);
DECLARE v_cost4 DECIMAL(7,2);
DECLARE v_cost5 DECIMAL(7,2);
SELECT coalesce(sum(cost),0) INTOv_cost1FROMCOMPRISES_AC_EQUIPMENT where
ENQUIRY_ID = v_enquiry_id;
SELECT coalesce(sum(cost),0) INTOv_cost2FROMCOMPRISES_CRANE where ENQUIRY_ID=
v_enquiry_id;
SELECT coalesce(sum(cost),0) INTOv_cost3FROMCOMPRISES_DISTRIBUTION where
ENQUIRY_ID = v_enquiry_id;
SELECT coalesce(sum(cost),0) INTOv_cost4FROMCOMPRISES_DUCTWORK where ENQUIRY_ID
= v_enquiry_id;
SET v_cost5 = v_cost1 + v_cost2 + v_cost3 + v_cost4;
UPDATE HVAC_ENQUIRY
SET Enquiry_Cost=v_cost5
where ENQUIRY_ID= v_enquiry_id;
END;
//
35. Team Datawesome |Project
34
Thisprocedure isusedto calculate the total HVACEnquiry costconsideringall the differentequipments,
ductwork,distributionandcranesinvolvedinthe enquiry.Once the individual costassociatedwithall
these partsare known,we calculate the final costasa summationof all these costs.LaterHVACEnquiry
table isupdatedwiththe total final cost.
Procedure 11:
Calculate the value of totalEnquiryCostinENQUIRY
DELIMITER //
CREATE PROCEDURE PROC_FINAL_COST_AGGREGATION (IN v_enquiry_idInt(5))
BEGIN
DECLARE v_cost1 DECIMAL(7,2);
DECLARE v_cost2 DECIMAL(7,2);
DECLARE v_cost3 DECIMAL(7,2);
SELECT coalesce(sum(cost),0) INTOv_cost1FROMRENTAL_DETAILS where ENQUIRY_ID=
v_enquiry_id;
SELECT coalesce(Enquiry_Cost,0) INTOv_cost2FROMHVAC_ENQUIRY where ENQUIRY_ID=
v_enquiry_id;
SET v_cost3 = v_cost1 + v_cost2;
UPDATE ENQUIRY
SET totalEnquiryCost=v_cost3
where ENQUIRY_ID= v_enquiry_id;
END;
//
Thisprocedure calculatesthe final total costassociatedwithagivenEnquiry.Here we take the costfrom
the HVACEnquirytable andthenadd it withthe Rental detailsequipmentcosttogetthe Final total
EnquiryCost.Thisvalue isupdatedinthe Enquirytable.
36. Team Datawesome |Project
35
6. Interface and Reports
Base URL: www.daphotons.in/emi
6.1 Admin Credentials:
Username:tandon@email.arizona.edu
Password: shikhar
6.2 User Credentials:
Username:jahnavis@email.arizona.edu
Password: sambarrice
6.3 Admin Features
6.3.1 Login
1. Loginto Adminpanel usingthe admincredentials.If youtrytologinusingusercredentialsyou
will notbe able to login.
2. As soonas youloginyoushouldbe able tosee the monthlyreport.Youcan use the Search
feature inthe reportto filteron anyfield
37. Team Datawesome |Project
36
6.3.2 Add User Functionality
1. Clickon adduserlink
2. Enter usercredentialsandclickonadduser.The userwill getadded.
38. Team Datawesome |Project
37
6.3.3 Remove User Functionality
1. Clickon Remove user
2. Clickon “Remove”linkbeside the username.Andthisshould removethe user.
6.3.4 Modifying the data tables
1. Clickon the Table Name inthe left.
2. Insertrecordusingthe insertfunctionality.
3. Update / Delete usingthe update anddelete buttons.
39. Team Datawesome |Project
38
Clickon logouttoget outof adminpanel.
6.4 User Features
6.4.1 User Report
1. Loginto User Panel usingthe usercredentials.
2. The panel will have alistof enquiriesprocessedbyall usersforall customers.Youcan use the
searchfunctionalitytotofilteronanyvalues.
6.4.2 Add Customers
1. Clickon Customerslinkinthe header
2. It will give alistof the Customersindatabase.
3. Enter Credentialsinthe formbelow toadda new customers.
4. Clickon the add customerslinktoto add a new customer.
6.4.3 Create Enquiry
Clickon HVACEnquiryto create a HVACEnquiry
1. Selectcustomerfromthe drop down(Note:If youaddcustomer, it will automaticallyappearinthe
drop downwithoutanycode modification)
40. Team Datawesome |Project
39
2. Selectthe OptionsinGeneral InfoandEquipmentDetails,Accessories,Ductwork,Crane, Distribution,
RentalsandEquipment.
3. Clickon submit.
4. The phpcode will update dataviaajax and once all data has beenupdateditwill gotothe home
screenshowingyouthe total cost.
5. Clickon logoutto go outof the userscreen.
6.4.4 Other Features:
1. ProtectedAccess:
a. Try to go to the user panel oradminpanel afterloggingout.Itwill denyaccess.
b. Try to access the adminpanel afterloggingintothe userpanel.Itwill denyaccess
c. Try to access the userpanel afterloggingintothe adminpanel.Itwill denyaccess
2. Dynamic menu’s:All the attributesinthe Enquirycreationpage are dynamicallyretrievedfrom
mastertableswhichcan be editedbythe admin.Toview this.,youcanadd a new accessoryin
the adminpanel andcheck through the userpanel if itis beingpopulatedorno
3. Concurrent users:Many userscan loginandcreate inquiriesatthe same time. Youcan login
fromtwo useridsand create inquiryatthe same time.Althoughthiswasnotaspecified
requirementitwasgivenvia sessioncontrol.
41. Team Datawesome |Project
40
7. Conclusion and Implementation Plan
7.1 Conclusion:
Thisprojectwas a great learningexperienceforthe team.Asthe projectprogressedwe,the team
members,watchedthe groupevolveandgainmore knowledge andunderstandingof notonlytechnical
skillssuchasdatabase conceptsbut alsosoftskillssuchasclientandprojectmanagement.
Belowisthe summaryof team DataWESOME’s keylearningexperiences:
ProjectandClientManagementskills:
Thisprojectwas a great experience forthe teamtohone itsprojectandclientmanagementskills.Right
fromgettinga client,tomeetingwiththe clienttogatherrequirementsanddesigningaprototype,this
projectwasa greatway forthe teamto demonstrate itsabilitytohandle areal life clientwithareal life
database problemtoaddress.Importanttoolssuchas translationof requirementsintoERdiagrams,
Conversionof ERdiagramsto tablesandNormalizationreallyhelpedthe teamineffectivelycapturing
the clientrequirementsandcommunicatingwiththe clientthe informationthatwasneeded.
7.2 Technical skills
Althoughthe teaminitiallyplannedtocreate adatabase usingOracle,afterthe initial meetingswiththe
client,the teamdecided touse MySQLin orderto helpsave the clientfromspendingonOracle licenses.
The team washence taskedwiththe goal of usingOracle knowledge tograspMySQL. Initially,itdid
seemlike adauntingtaskforthe teamto use a differentplatformfromwhat wastaughtin class.But as
42. Team Datawesome |Project
41
we got more comfortable withthe SQLcode,the teamwas slowlyable totransitionfromOracle to
MySQL. By the endof the projectthe teamgot fairlycomfortable usingMySQL.Thisabilitytotransition
fromone language to another,we believe waskeyinourlearningexperience.Theseare skillsthatmake
us adaptable professionalandwhichwe see ourselvesusingmore of.
As we progressedinthe project,the teamalsogotto implementalotof the gooddatabase practices
that were learntitclass.For example,the teammade sure dataentitiesandtableswere namedina
logical waythat wouldbe easytomaintain.Anotherexample wouldbe choosingagoodprimarykeyand
relatingtableswithappropriateforeignkeys.Apartfromthis,the teamalsogotto explore andlearn
more about frontenddesign.Since simplicitywasparamountforourclient,the teammade sure to
developasimple andveryfunctionaluserinterface thatallowedtwomodes:AdministratorandUser.
Thiswas done,keepingthe enduserinmindandensuringoptionsandmenusstrategicallycateredto
the right usertype.
Overall,thisprojectwasagreat opportunityforthe teamto demonstrate notonlyitstechnical skills
such as SQL development,ERmodellingandNormalization,butalsoitssoftskillssuchasClientand
Projectmanagement.The teamwasable todeliveraprototype thatthe clearlyaddressedthe clients
needandthe clientwashappywiththe endresult.The clientalsocommendedthe teamforits
successful deliveryof the prototype andexpressedinterestof workingwiththe MISstudentsof Eller
College of Managementinfuture projects.
7.3 Implementation plan for real world DBMS
These are the plannedstepsforimplementingthe applicationinthe real world:
1. Improve the securityandcreate a fullyfunctional UI
2. Migrate the existingMySQLdatabase to Client’scloud
3. Host the PHP applicationonthe clientserver/website
4. Provide properdocumentationwhichwill helpanymodificationsrequired
43. Team Datawesome |Project
42
The firststepbefore implementationwouldbe toimprove the securityfeaturesof the application.
The followingsecurityfeatures canbe added:
1. SQL Injection:Thisisa common methodof cyberhackingattacks andfeaturesmustbe
implementedtoavoidSQLinjectionattacks.
2. Error Messages:Genericerrormessagesmustbe displayed,use of specificerrormessageswill
assisthackersusingbrute force penetrate the applicationwithease.
3. Serverside validation: Validationhastobe done bothon the serverside andonthe website to
ensure extrasecurity
4. Strong Passwords: Currentlywe donot have anyrulesfor passwords,we have toensure that
strongpasswordsare createdwiththe helpof regularexpressionsandotherfeatures.
5. SSL certificates:If possible,higherlevel of securitymustbe providedusingSSLcertificates.This
isnot mandatory,however,wouldbe agoodvalue addand will make the website more secure.
Our teamwill implementsome of the above basicsecuritymeasuresbeforehostingthe applicationon
the client’ssite.Apartfromthe securityfeatures,we have toensure thatthe User Interface isfully
functional andexactlymatchesourclient’srequirements.We are alreadyworkingonthisandwe are on
our final stages.
The database is goingto be implementedviaMySQLon the client’scloudasour clientwantsanopen
source solutionandthe data base isalsoof moderate size.Mostof the importantdata can be added,
removedandmodifiedviathe UserInterface whichmeansthatourclientdoesn’thave toupdate or
workwiththe databases.However,if inextremecases,if new tableshave tobe addedor existingtable
structure has to be modified,the datadictionaryandthe documentwe providewill helpthemdothe
changeswithoutanyhassles.
The applicationasa whole isgoingto be implementedonthe client’swebsite.Ourclientalreadyhasa
workingwebsiteandthe applicationwill be hostedonit.Since itsprimarycode isinbasicPHP and
HTML, eventhiswouldn’tcostanylicensestoourclients.The applicationwill alsohave be password
protectedandwill provide differentlevelsof accessto administratorsandthe users.The varioussecurity
featuresthatwill be implementedwillmake sure thatthe data isalwayssecure withinthe application.
44. Team Datawesome |Project
43
The most importantpart of our implementationwouldbe tomake the applicationflexible sothatany
future modificationscanbe accommodated.Thiscanbe achievedwhenthe applicationisproperly
documented.Alongwiththe report,we will alsosubmitthe requireddocumentationwhichwill enable
the clienttoeasilymodifythe applicationinthe future.
7.4 Cost Estimation
The Cost Estimatesforthe Software,Database andthe worklabouris as givenbelow:
Category Total Units Cost per unit(in
USD)
Total Cost (in USD)
Person Hours:
Design 90 700 $63,000
Implementation 60 600 $36,000
Testing 90 500 $45000
Development
Software:
MySQL 10 6000 $60,000
PHP 10 3000 $30,000
Database:
Amazon AWS 1 50000 $50,000
45. Team Datawesome |Project
44
8. APPENDIX
8.1 Appendix to Chapter 3
8.1.1 SQL Statements to create tables
-- Drop all tables
SET foreign_key_checks=0;
DROP TABLE ACCESSORIES;
DROP TABLE AC_EQUIPMENT;
DROP TABLE AC_EQUIPMENT_ELECTRICAL;
DROP TABLE AC_EQUIPMENT_SIZES;
DROP TABLE CRANE;
DROP TABLE CUSTOMER;
DROP TABLE CUSTOMER_CONTACT_NUMBER;
46. Team Datawesome |Project
45
DROP TABLE DISTRIBUTION;
DROP TABLE DUCTWORK;
DROP TABLE SPIRAL;
DROP TABLE SQUARE;
DROP TABLE FLEX;
DROP TABLE ENGINEERS;
DROP TABLE ENGINEERS_CONTACT_NUMBER;
DROP TABLE ENQUIRY;
DROP TABLE HVAC_ENQUIRY;
DROP TABLE PLUMBING_ENQUIRY;
DROP TABLE FEATURES;
DROP TABLE OTHER_WORKERS;
DROP TABLE RENTAL_EQUIPMENTS;
DROP TABLE SUBCONTRACTORS;
DROP TABLE SUBCONTRACTORS_CONTACT_NUMBER;
47. Team Datawesome |Project
46
DROP TABLE COMPRISES_CRANE;
DROP TABLE COMPRISES_DUCTWORK;
DROP TABLE COMPRISES_ACCESSORIES;
DROP TABLE COMPRISES_DISTRIBUTION;
DROP TABLE COMPRISES_AC_EQUIPMENT;
DROP TABLE PLMB_FEATURES;
DROP TABLE RENTAL_DETAILS;
DROP TABLE SUBCONTRACT;
DROP TABLE OTHER_WORK;
SET foreign_key_checks=1;
-- Strong EntityClass - 1
CREATE TABLE ACCESSORIES(
accessories_id Int(3) AUTO_INCREMENT,
name Varchar(50),
price Decimal(7,2),
CONSTRAINTACCESSORIES_pkPRIMARYKEY(accessories_id));
-- Strong EntityClass - 2
CREATE TABLE AC_EQUIPMENT (
ac_equipment_ID Int(3) AUTO_INCREMENT,
equipment_Type Varchar(50),
57. Team Datawesome |Project
56
CONSTRAINTWork_fk0FOREIGN KEY(enquiry_ID) REFERENCESENQUIRY(enquiry_ID),
CONSTRAINTWork_fk1FOREIGN KEY(worker_ID) REFERENCESOTHER_WORKERS(worker_ID),
CONSTRAINTWork_pkPRIMARYKEY(enquiry_ID,worker_ID));
8.2 Procedures
/*1. Procedure - To create newenquiryidinENQUIRYtable,new ac_order_idinAC_ORDER table and
alsocorrespondingrowinHVAC_ENQUIRYtable*/
DELIMITER //
CREATE PROCEDURE PROC_ENQUIRY_ID(IN in_user_idInt(11))
BEGIN
DECLARE v_enquiry_idINT(5);
INSERT INTOENQUIRY (ENQUIRY_DATE,enquiryType,user_id) VALUES(DATE(SYSDATE()
),'HVAC',in_user_id);
SELECT MAX(ENQUIRY_ID) INTOv_enquiry_idfromENQUIRY;
INSERT INTOHVAC_ENQUIRY(ENQUIRY_ID,ENQUIRY_COST) VALUES (v_enquiry_id,0);
END;
//
/*CALL PROC_ENQUIRY_ID();*/
/*2. Procedure toupdate Plan,Engineer,Construction_Type andcustomer_idinENQUIRY*/
DELIMITER //
CREATE PROCEDURE PROC_ENQUIRY_PLAN (IN v_enquiry_idInt(5),IN in_customer_idInt(3),IN in_plan
VARCHAR(50),
IN in_engineer_idINT(3),IN in_construction_type VARCHAR(50))
BEGIN
58. Team Datawesome |Project
57
UPDATE ENQUIRY
SET PLAN = in_plan, ENGINEER_ID= in_engineer_id,CONSTRUCTION_TYPE=
in_construction_type,customer_ID=in_customer_id
WHERE ENQUIRY_ID = v_enquiry_id;
END;
//
/*CALL PROC_ENQUIRY_PLAN (''*/
/*3. Procedure toinsertintoCOMPRISES_AC_EQUIPMENTTABLE */
DELIMITER //
CREATE PROCEDURE PROC_COMPRISES_AC_EQUIPMENT(IN v_enquiry_idInt(5),IN
in_ac_equipment_idInt(3),
IN in_qtyInt(3),IN in_ac_equipment_electrical_id Int(3),in_ac_equipment_sizes_idInt(3))
BEGIN
DECLARE v_cost1 Decimal(7,2);
DECLARE v_cost2 Decimal(7,2);
SELECT price INTOv_cost1 FROMAC_EQUIPMENT WHERE ac_equipment_ID=
in_ac_equipment_id;
SET v_cost2 = v_cost1 * in_qty;
INSERT INTOCOMPRISES_AC_EQUIPMENT
(ac_equipment_ID,enquiry_ID,ac_equipment_electrical_id,ac_equipment_sizes_id,ac_equipment_qty,c
ost)
VALUES
(in_ac_equipment_id,v_enquiry_id,in_ac_equipment_electrical_id,in_ac_equipment_sizes_id,in_qty,v_c
ost2);
59. Team Datawesome |Project
58
END;
//
/*4. Procedure toinsertintoCOMPRISES_ACCESSORIESTABLE*/
DELIMITER //
CREATE PROCEDURE PROC_COMPRISES_ACCESSORIES(IN v_enquiry_idInt(5),IN in_accessories_id
Int(3))
BEGIN
INSERT INTOCOMPRISES_ACCESSORIES(enquiry_id,accessories_id)
VALUES (v_enquiry_id,in_accessories_id);
END;
//
/*4. Procedure toinsertintoCOMPRISES_DUCTWORK*/
/* For Flex */
DELIMITER //
CREATE PROCEDURE PROC_COMPRISES_DUCTWORK_FLEX(IN v_enquiry_idInt(5),IN in_type
Varchar(50),IN in_size Varchar(50),
IN in_linearFootageDecimal(6,2),IN in_rval Decimal(4,2))
BEGIN
60. Team Datawesome |Project
59
DECLARE v_ductwork_idINT(3);
DECLARE v_cost1 Decimal(7,2);
SELECT ductwork_idINTOv_ductwork_idFROMDUCTWORK
WHERE ductwork_type =in_type ANDsizes= in_size;
SELECT price INTOv_cost1 FROMDUCTWORK
WHERE ductwork_type =in_type ANDsizes= in_size;
INSERT INTOCOMPRISES_DUCTWORK(enquiry_id,ductwork_id,linearFootage,rValue,cost)
VALUES (v_enquiry_id,v_ductwork_id,in_linearFootage,in_rval,v_cost1);
END;
//
/* For Square and Spiral */
DELIMITER //
CREATE PROCEDURE PROC_COMPRISES_DUCTWORK_SQUARESPIRAL(IN v_enquiry_idInt(5),IN in_type
Varchar(50),IN in_size Varchar(50),
IN in_linearFootageDecimal(6,2),IN in_insVarchar(50))
BEGIN
DECLARE v_ductwork_idINT(3);
DECLARE v_cost1 Decimal(7,2);
IF (in_type ='SPIRAL') THEN
IF (in_ins='Wrapped') THEN
SELECT d.ductwork_idINTOv_ductwork_idFROMDUCTWORKd JOIN SPIRALs
ON d.ductwork_ID=s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isWrapped ='Y';
61. Team Datawesome |Project
60
SELECT d.price INTOv_cost1 FROMDUCTWORK d JOIN SPIRALs ON
d.ductwork_ID= s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isWrapped='Y';
ELSEIF (in_ins= 'Lined') THEN
SELECT d.ductwork_idINTOv_ductwork_id FROMDUCTWORKd JOIN SPIRALs
ON d.ductwork_ID=s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isLined='Y';
SELECT d.price INTOv_cost1 FROMDUCTWORK d JOIN SPIRALs ON
d.ductwork_ID= s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isLined='Y';
END IF;
ELSEIF (in_type ='SQUARE') THEN
IF (in_ins='Wrapped') THEN
SELECT d.ductwork_idINTOv_ductwork_idFROMDUCTWORKd JOIN SQUARE s
ON d.ductwork_ID=s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isWrapped='Y';
SELECT d.price INTOv_cost1 FROMDUCTWORK d JOIN SQUARE s ON
d.ductwork_ID= s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isWrapped='Y';
ELSEIF (in_ins= 'Lined') THEN
SELECT d.ductwork_idINTOv_ductwork_idFROMDUCTWORKd JOIN SQUARE s
ON d.ductwork_ID=s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isLined='Y';
SELECT d.price INTOv_cost1 FROMDUCTWORK d JOIN SQUARE s ON
d.ductwork_ID= s.ductwork_ID
WHERE d.ductwork_type =in_type ANDd.sizes=in_size ANDs.isLined='Y';
END IF;
END IF;