SlideShare a Scribd company logo
1 of 32
[DBDS DataBase Design Specialists, Inc.]
“We are always 5NF”
Bears in Canada Project
[Final Project Report]
Chakrabarti, Shreya NN: 06
Data Architect
[The Document contains Final Report pertaining to Bears in Canada Project]
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
2 | P a g e
Table of Contents
Topic Page
 Introduction 3
 ProblemStatement 3
 ProposedSolution 3
 Functional Dependencies 4
1. Graphical Representation 6
 Design 7
1. Logical Data Model 7
2. Physical Data Model 7
 Query Results 8
 Memo#7 14
 Appendix 16
1. Data DefinitionLanguage (DDL) for creatingrelationsin Database 16
2. Insert Statementsfor InsertingData to the Database 21
3. Validationof the InsertedData 24
4. DesignRevolutions 30
a. Logical Model Version:1 30
b. Physical Model Version:1 30
c. Logical Model Version:2 31
d. Physical Model Version:2 31
 Explanation for changingPreviousLDM and PDM 32
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
3 | P a g e
Introduction
The Projectwas undertakenbyauthoritiesinCanadato
keeptrack of populationandhealthstatisticsof the
decreasingeverincreasingBearPopulationof Canada.
The projectis abouttrackingthe locationandhealthof
bearsin or neara national parkin Canada.Tracking is
done bythree differentmethods:telemetrytracking
(aftera bearhas beencapturedandtracking device has
beenattached),hairsnags(foundonbushesandtrees
inthe area),andscats (animal feces) located by
speciallytraineddogs. DNA datafromhair and scat
samplescanbe usedtodetermine the sex of the bear
and some healthdata.The Scat samplesprovide
individualizeddataonthe physiological healthof that
animal.The total area of the National Parkisdivided
intomanyregions inwhichstudiesare beingconducted.
The regionsandother detailscanbe foundinthe map
alongside.
ProblemStatement
The existingdatasethasthe followinginconsistencies
 Data Redundancy,Noproperstorage forthe data
 No Categorizationof the data
 No ProperData HandlingMethods
The database for BIC implementedthroughthisprojectwill addressthe above identifiedProblems
ProposedSolution
The newdatabase wouldbe designedusingthe below steps
 List of (charts of) Functional Dependencies
 A relational database design(5NF) –a logical DataModel,and a correspondingPhysicalDataModel
 A prototype of relational databasedesign(RDD) generatedbyErwinusingSQLServer2014
 Results,fromthe prototype database,forqueries(questions)
Functional Dependencies
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
4 | P a g e
Bottom Up
SpeciesCode ->Average PHT
Average PHT-> SpeciesCode
RegionID-> Size
StudyName -> RegionID
StudyName -> StudyID
StudyID -> StudyName
StudyName -> Size
StudyID -> RegionID
StudyID -> Size
Location-> RegionID
Location-> Size
Sample Number->Status
ParticipantID-> NumberSamples
NumberSamples ->ParticipantID
ParticipantID-> Name
Name -> ParticipantID
Start Date -> ParticipantID
ParticipantID-> Start Date
Name -> NumberSamples
Start Date -> NumberSamples
Start Date -> Name
StudyID -> Study
Name
ParticipantID-> NumberSamples
ParticipantID-> Name
ParticipantID-> Start Date
SpeciesCode ->Average PHT
Name
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
5 | P a g e
Top Down Approach
From the enterprise statementwe have the below FD’s
ParticipantID-> End Date
Sample_Number->Location
Animal Number,StudyID->Sex
List of Tablesdeterminedfromthe FD’s
 Participant->{Participant ID, Participant-Name,Start-Date,End-Date}
Participant_ID– PrimaryKey
 Region->{RegionID, RegionName,Size ParticipantID(F.K) }
RegionID–Primary Key
ParticipantID– ForeignKey
 Study -> {Study ID, Study-Name,RegionID(F.K)}
StudyID – PrimaryKey
RegionID– ForeignKey
 Classification ->{ClassID, ClassificationName}
ClassID – PrimaryKey
 Status-> {Status ID, StatusName}
StatusID –Primary Key
 SpeciesType ->{Species_Code,SpeciesName,AveragePHT}
SpeciesCode –PrimaryKey
 Animal ->{Animal Number,Study ID, SpeciesCode(FK),Sex}
Animal Number->PrimaryKey
StudyID -> PrimaryKey
SpeciesCode ->ForeignKey
 Sample_Details ->{Sample_Number,ClassID,StudyID(F.K),AnimalNumber(F.K),Status(F.K),Sample Date,
Location}
Sample Number->PrimaryKey
ClassID -> Composite PrimaryKey
StudyID, Animal Number,Status ->ForeignKey
ClusteredPrimaryKey
ClusteredPrimaryKey
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
6 | P a g e
Graphical Representation
Species
Code
RegionID
StudyName
Study
ID
Size
ClassID
Average
PHT
PHT
Value
Animal
Number
Location
Sample
Date
Sample
Number
Sex
Status
Participant
ID
Number
Samples
Name
StartDate
End
Date
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
7 | P a g e
Design
Logical Data Model for Bears in Canada Project
Physical Data Model for Bears in Canada Project
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
8 | P a g e
Query Results
(Memo:#3)
1) What isthe largestphysiological healthvalueobservedforablackbear?
Query:
Use BIC06;
SELECT MAX(PHT_Value) as 'Largest Physiological Health Value of a black bear'
FROM Scat JOIN Sample_Details on Scat.[Sample_Number] = Sample_Details.[Sample_Number]
join Animal on Sample_Details.Animal_Number = Animal.Animal_Number
where Species_Code = 'B';
Go
Result:
Largest Physiological Health Value of a black bear
--------------------------------------------------
120
Warning: Null value is eliminated by an aggregate or other SET operation.
(1 row(s) affected)
2) For eachanimal,listall of itssample classificationsinchronological (date) order
Query:
use BIC06;
select
Class_ID as Classification,
Animal_Number as Animal,
cast(Sample_Date as nvarchar) as Sample_Date
from
Sample_Details
group by
cast(Sample_Date as nvarchar),
Animal_Number,
Class_ID
Go
Result:
Classification Animal Sample_Date
------------------ ----------- -------------------
S 118 2014/06
S 42 2014/07
S 63 2014/07
H 66 2014/07
S 66 2014/07
S 112 2014/07
S 113 2014/07
S 42 2014/08
T 59 2014/09
S 114 2014/10
T 114 2014/10
T 66 2014/11
H 89 2014/11
S 50 2015/07
S 59 2015/09
H 113 2015/10
(16 row(s) affected)
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
9 | P a g e
3) In whatregionisthe Central 2014 studyand whatsize andgrid pattern isusedon that study
Query:
use BIC06;
Select Region_Name, Size
From Region, Study
Where Region.[RegionID] = Study.[RegionID]
and Study_Name = 'Central 2014';
GO
Result:
Region_Name Size
------------------ ------------------
Central Region 9X9
(1 row(s) affected)
4) List the animalsthatare within5unitsof theiraverage physiological healthvalue
Query: Use BIC06;
select Animal_Number, ph as PHT_Value, Average_PHT, Species_Name
from (select first.Animal_Number, ph, species_code
from (select Animal_Number,avg(PHT_Value) as ph from sample_details
join scat on sample_details.Sample_Number = scat.Sample_Number group by animal_number) as first
join Animal as a on first.Animal_Number = a.Animal_Number group by first.animal_number, ph,
species_code) as animal
join species_type on animal.species_code = species_type.species_code where ph between Average_PHT-
5 and Average_PHT+5;
Go
Result:
Animal_Number PHT_Value Average_PHT Species_Name
------------- ---------------------- --------------------------------------- --------------------
42 112 113 Black Bear
63 117 113 Black Bear
Warning: Null value is eliminated by an aggregate or other SET operation.
(2 row(s) affected)
5) List the sample informationforCentral 2014 studiesmade inSeptember2014 and November2014
Query:
Use BIC06;
SELECT Study_Name, Sample_Number, Sample_Date, Class_ID, [Status], Location, Animal_Number
FROM Sample_Details JOIN Study ON Sample_Details.Study_ID = Study.Study_ID
where Study_Name = 'Central 2014' and (cast(Sample_Date as nvarchar) = '2014/09' or
cast(Sample_Date as nvarchar) = '2014/11');
GO
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
10 | P a g e
Result:
Study_Name Sample_Number Sample_Date Class_ID Status Location Animal_Number
-------------------- ------------- -------------------- ------------------ ----------- --------
Central 2014 44 2014/09 T 0 32:1:9 59
Central 2014 47 2014/09 T 0 41:2:3 59
Central 2014 82 2014/11 T 0 31:5:8 66
(3 row(s) affected)
6) What Studieshave animalsforwhichsampleswere gatheredinJuly2014
Query:
Use BIC06;
SELECT Study_Name,Sample_Number,Animal_Number,Sample_Date
FROM Sample_Details JOIN Study ON Sample_Details.Study_ID = Study.Study_ID
JOIN Region ON Region.RegionID=Study.RegionID
Where cast(Sample_Date as nvarchar) = '2014/07'
GO
Result:
Study_Name Sample_Number Animal_Number Sample_Date
-------------- ---------------------- ------------- ------------------------
North 2014 11 113 2014/07
North 2014 17 42 2014/07
South 2014 45 63 2014/07
South 2014 68 66 2014/07
Central 2015 79 112 2014/07
North 2014 100 66 2014/07
(6 row(s) affected)
7) What type of sampleswere collectedinthe South2014 Study
Query:
Use BIC06;
SELECT Distinct Study_Name,Classification_Name
FROM Study JOIN Sample_Details ON Study.Study_ID = Sample_Details.Study_ID
JOIN Classification ON Sample_Details.Class_ID = Classification.Class_ID
where Study_Name = 'South 2014'
GO
Result:
Study_Name Classification_Name
------------------------------ ------------------------------
South 2014 Hair Snag
South 2014 Scat
(2 row(s) affected)
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
11 | P a g e
(Memo:#4)
8) Who (Name andID) managesthe Central Region?
Query:
Use BIC06;
SELECT Region_name,Participant_Name,Region.[Participant_ID]
from Region Join Participant ON Region.[Participant_ID] = Participant.[Participant_ID]
Where Region_name = 'Central Region'
Go
Result:
Region_name Participant_Name Participant_ID
------------------ ------------------------- --------------------
Central Region Mary P0102
(1 row(s) affected)
9) Who (Name andID) has access data onsouth regionsample data?
Query:
Use BIC06;
Select P.[Participant_ID], Participant_Name from Participant AS P, Technicians AS
T,Other_Tracking__Methods as OT, Sample_Details AS S,Region AS R, Study, Manager as M
where (P.[Participant_ID]= OT.[Participant_ID]
AND T.[Participant_ID]= OT.[Participant_ID]
AND OT.Sample_Number = S.Sample_Number
AND OT.Class_ID = S.Class_ID
AND S.Study_ID=Study.Study_ID
AND Study.RegionID=R.RegionID
AND M.[Participant_ID]=R.[Participant_ID]
AND R.Region_Name = 'South Region')or(P.[Participant_ID]=M.[Participant_ID]
AND M.[Participant_ID]=R.[Participant_ID]
AND R.Region_Name='South Region') group by P.[Participant_ID],Participant_Name;
Go
Result:
Participant_ID Participant_Name
-------------------- --------------------
P0103 Fred Foreman
P2004 Jane Smith
P2045 Anne Dough
(3 row(s) affected)
10) How manytimeseachanimal hasbeensampled?
Query:
Use BIC06;
select Study_ID,Animal_Number, count(Animal_Number) as "Sampled_Times" from Sample_Details
Group by Animal_Number,Study_ID
Go
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
12 | P a g e
Result:
Study_ID Animal_Number Sampled_Times
-------- -------------- -------------
C14 59 2
C14 66 1
C14 113 1
C14 114 2
C15 50 1
C15 59 1
C15 112 1
N14 42 2
N14 66 1
N14 113 1
N14 118 1
S14 63 1
S14 66 1
S14 89 1
(14 row(s) affected)
11) List SamplesanalyzedbyP2045
Query:
use BIC06;
select Participant_ID,Sample_Details.[Sample_Number] from Sample_Details
INNER JOIN Other_Tracking__Methods ON Sample_Details.[Sample_Number]=
Other_Tracking__Methods.[Sample_Number]
where Participant_ID = 'P2045';
Go
Result:
Participant_ID Sample_Number
-------------------- ----------------------
P2045 22
P2045 47
P2045 82
(3 row(s) affected)
12) List Namesof Dogsthat have workedineach study
Query:
use BIC06;
select Distinct Participant.[Participant_ID],Participant_Name,Study_Name from Participant
inner join Dogs on Dogs.[Participant_ID] = Participant.[Participant_ID]
join Scat on Dogs.[Participant_ID] = Scat.[Participant_ID]
join Sample_Details on Scat.Sample_Number = Sample_Details.Sample_Number
join Study on Study.Study_ID = Sample_Details.Study_ID
go
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
13 | P a g e
Result:
Participant_ID Participant_Name Study_Name
-------------------- -------------------- --------------------
D0004 Max Central 2014
D0004 Max Central 2015
D0004 Max North 2014
D0008 Sampson North 2014
D0013 Cindy Central 2014
D0013 Cindy Central 2015
D0013 Cindy South 2014
D0022 Rover North 2014
(8 row(s) affected)
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
14 | P a g e
Memo:#7
Additional Data
1. New Data from Bob
1.1. The Newdata fromBob will notbe insertedintothe table.
 The firstrow has Sample_Number value asNull whichisaprimarykeyof Sample_Detailstable andwill
not allowaNull Value
 The SecondRow has noAnimal number whichisaprimaryKeyof Animal Table andtherefore cannotbe
Null andtherefore thisrowalsowill notbe added
 Althoughall the valuesforthe thirdtuple existSample Number59alreadyexistsinthe Datasetandas
Sample_Numbercannotbe duplicate (PrimaryKeyConstraint) thisrow toowill notbe addedtothe
database
 The additionof these Tuplesisnotpossible because of PrimaryKeyConstraint
 No MetadataChanges
2. InformationfromSam
2.1. There isto be a newStudyinthe central Regionso the StudyName forCentral 2016
 The study can be addedeasilytothe existingdata
 Thiswill require onlyone InsertstatementtoInsertthe new StudyintoStudyTable
 The central regionalreadyexiststhereforeonlyone Insertstatementisrequiredtoaddthe data
 SQL Querythat can be usedforthe insertisas below:
use BIC06;
INSERT INTO Study VALUES ('C16', 'Central 2016', 'CR');
Go
 No MetadataChanges
2.2. NewStatisticshave beenmade availableandtheyshow thatthe current bestestimate forthe average PHTfor
Black Bearis 115 and not 113
 The update will not have anyissuesinthe design
 Onlythe Average_PHTvalue inSpecies_Type wouldneedtobe updated
 There isno change requiredinthe design
 SQL QUERY that can be usedforthe update is as below:
USE BIC06;
UPDATE Species_Type
SET Average_PHT= 113
WHERE Species_Code='B';
Go
 No MetadataChanges
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
15 | P a g e
3. Data Items from Bob that ‘’Look Different’’
 Thisanimal can be tracked easily asthe data providedcanbe addedintothe database
 As seenearlierinthe database same animal canbe tracked multiple times
 Therefore thisAnimal canbe declaredinthe Animal Table andthentrackedindifferentstudiesusing
differentsample Numbers
 The newrow insertionwill nothave anyprimarykeyor referential keyintegrity constraint
 SQL QUERY that can be usedforthe update is as below:
INSERT INTO Animal VALUES (200, 'F', 'B', 'N14');
INSERT INTO Sample_Details VALUES (77, '2014/07' ,'T',1,'23:1:9',200,'N14');
INSERT INTO Sample_Details VALUES (78, '2014/07' ,'T',1,'29:1:1',200,'N14');
 No MetadataChanges
4. Number ofSamplesField
 The Fieldcan be droppedeasilyasitisneitherPrimarynorForeignKeyforthe dogstable
 There will be metadatachange forremovingthe fieldfromthe DogsTable
 SQL QUERY that can be usedforthe delete isasbelow:
ALTER TABLE Dogs
DROP COLUMN Number_Samples;
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
16 | P a g e
Appendix:
Data DefinitionLanguage (DDL) for creatingrelationsin Database
CREATE TABLE [Animal]
(
[Animal_Number] int NOT NULL ,
[Sex] char(1) NULL ,
[Species_Code] char(1) NOT NULL ,
[Study_ID] char(3) NOT NULL
)
go
ALTER TABLE [Animal]
ADD CONSTRAINT [XPKAnimal] PRIMARY KEY CLUSTERED ([Animal_Number] ASC,[Study_ID] ASC)
go
CREATE TABLE [Classification]
(
[Class_ID] char(18) NOT NULL ,
[Classification_Name] char(18) NULL
)
go
ALTER TABLE [Classification]
ADD CONSTRAINT [XPKClassification] PRIMARY KEY CLUSTERED ([Class_ID] ASC)
go
CREATE TABLE [Director]
(
[Participant_ID] char(20) NOT NULL ,
[Next_Inspection_Date] date NULL
)
go
ALTER TABLE [Director]
ADD CONSTRAINT [XPKDirector] PRIMARY KEY CLUSTERED ([Participant_ID] ASC)
go
CREATE TABLE [Dogs]
(
[Participant_ID] char(20) NOT NULL ,
[Number_Samples] int NULL
)
go
ALTER TABLE [Dogs]
ADD CONSTRAINT [XPKDogs] PRIMARY KEY CLUSTERED ([Participant_ID] ASC)
go
CREATE TABLE [Manager]
(
[Participant_ID] char(20) NOT NULL ,
[Last_Access_Log] datetime NULL
)
go
ALTER TABLE [Manager]
ADD CONSTRAINT [XPKManager] PRIMARY KEY CLUSTERED ([Participant_ID] ASC)
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
17 | P a g e
go
CREATE TABLE [Other_Tracking__Methods]
(
[Sample_Number] float(20) NOT NULL ,
[Class_ID] char(18) NOT NULL ,
[Participant_ID] char(20) NULL
)
go
ALTER TABLE [Other_Tracking__Methods]
ADD CONSTRAINT [XPKOther_Tracking__Methods] PRIMARY KEY CLUSTERED ([Sample_Number]
ASC,[Class_ID] ASC)
go
CREATE TABLE [Participant]
(
[Participant_ID] char(20) NOT NULL ,
[Participant_Name] char(20) NULL ,
[End_Date] date NULL ,
[Start_Date] date NULL
)
go
ALTER TABLE [Participant]
ADD CONSTRAINT [XPKParticipant] PRIMARY KEY CLUSTERED ([Participant_ID] ASC)
go
CREATE TABLE [Region]
(
[RegionID] char(18) NOT NULL ,
[Region_Name] char(18) NULL ,
[Size] char(18) NULL ,
[Participant_ID] char(20) NULL
)
go
ALTER TABLE [Region]
ADD CONSTRAINT [XPKRegion] PRIMARY KEY CLUSTERED ([RegionID] ASC)
go
CREATE TABLE [Sample_Details]
(
[Sample_Number] float(20) NOT NULL ,
[Sample_Date] char(20) NULL ,
[Class_ID] char(18) NOT NULL ,
[Status] int NOT NULL ,
[Location] char(20) NULL ,
[Animal_Number] int NOT NULL ,
[Study_ID] char(3) NOT NULL
)
go
ALTER TABLE [Sample_Details]
ADD CONSTRAINT [XPKSample_Details] PRIMARY KEY CLUSTERED ([Sample_Number] ASC,[Class_ID] ASC)
go
CREATE TABLE [Scat]
(
[Class_ID] char(18) NOT NULL ,
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
18 | P a g e
[PHT_Value] float(20) NULL ,
[Sample_Number] float(20) NOT NULL ,
[Participant_ID] char(20) NULL
)
go
ALTER TABLE [Scat]
ADD CONSTRAINT [XPKScat] PRIMARY KEY CLUSTERED ([Class_ID] ASC,[Sample_Number] ASC)
go
CREATE TABLE [Species_Type]
(
[Species_Code] char(1) NOT NULL ,
[Average_PHT] decimal(20) NULL ,
[Species_Name] char(20) NULL
)
go
ALTER TABLE [Species_Type]
ADD CONSTRAINT [XPKSpecies_Type] PRIMARY KEY CLUSTERED ([Species_Code] ASC)
go
CREATE TABLE [Status]
(
[Status] int NOT NULL ,
[Status_Name] char(20) NULL
)
go
ALTER TABLE [Status]
ADD CONSTRAINT [XPKStatus] PRIMARY KEY CLUSTERED ([Status] ASC)
go
CREATE TABLE [Study]
(
[Study_ID] char(3) NOT NULL ,
[Study_Name] char(20) NULL ,
[RegionID] char(18) NOT NULL
)
go
ALTER TABLE [Study]
ADD CONSTRAINT [XPKStudy] PRIMARY KEY CLUSTERED ([Study_ID] ASC)
go
CREATE TABLE [Technicians]
(
[Participant_ID] char(20) NOT NULL
)
go
ALTER TABLE [Technicians]
ADD CONSTRAINT [XPKTechnicians] PRIMARY KEY CLUSTERED ([Participant_ID] ASC)
go
ALTER TABLE [Animal]
ADD CONSTRAINT [R_119] FOREIGN KEY ([Species_Code]) REFERENCES [Species_Type]([Species_Code])
ON DELETE NO ACTION
ON UPDATE NO ACTION
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
19 | P a g e
go
ALTER TABLE [Animal]
ADD CONSTRAINT [R_120] FOREIGN KEY ([Study_ID]) REFERENCES [Study]([Study_ID])
ON DELETE NO ACTION
ON UPDATE NO ACTION
go
ALTER TABLE [Director]
ADD CONSTRAINT [R_136] FOREIGN KEY ([Participant_ID]) REFERENCES [Participant]([Participant_ID])
ON DELETE CASCADE
ON UPDATE CASCADE
go
ALTER TABLE [Dogs]
ADD CONSTRAINT [R_65] FOREIGN KEY ([Participant_ID]) REFERENCES [Participant]([Participant_ID])
ON DELETE CASCADE
ON UPDATE CASCADE
go
ALTER TABLE [Manager]
ADD CONSTRAINT [R_137] FOREIGN KEY ([Participant_ID]) REFERENCES [Participant]([Participant_ID])
ON DELETE CASCADE
ON UPDATE CASCADE
go
ALTER TABLE [Other_Tracking__Methods]
ADD CONSTRAINT [R_70] FOREIGN KEY ([Sample_Number],[Class_ID]) REFERENCES
[Sample_Details]([Sample_Number],[Class_ID])
ON DELETE CASCADE
ON UPDATE CASCADE
go
ALTER TABLE [Other_Tracking__Methods]
ADD CONSTRAINT [R_131] FOREIGN KEY ([Participant_ID]) REFERENCES [Technicians]([Participant_ID])
ON DELETE NO ACTION
ON UPDATE NO ACTION
go
ALTER TABLE [Region]
ADD CONSTRAINT [R_138] FOREIGN KEY ([Participant_ID]) REFERENCES [Manager]([Participant_ID])
ON DELETE NO ACTION
ON UPDATE NO ACTION
go
ALTER TABLE [Sample_Details]
ADD CONSTRAINT [R_118] FOREIGN KEY ([Status]) REFERENCES [Status]([Status])
ON DELETE NO ACTION
ON UPDATE NO ACTION
go
ALTER TABLE [Sample_Details]
ADD CONSTRAINT [R_126] FOREIGN KEY ([Class_ID]) REFERENCES [Classification]([Class_ID])
ON DELETE NO ACTION
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
20 | P a g e
ON UPDATE NO ACTION
go
ALTER TABLE [Sample_Details]
ADD CONSTRAINT [R_135] FOREIGN KEY ([Animal_Number],[Study_ID]) REFERENCES
[Animal]([Animal_Number],[Study_ID])
ON DELETE NO ACTION
ON UPDATE NO ACTION
go
ALTER TABLE [Scat]
ADD CONSTRAINT [R_71] FOREIGN KEY ([Sample_Number],[Class_ID]) REFERENCES
[Sample_Details]([Sample_Number],[Class_ID])
ON DELETE CASCADE
ON UPDATE CASCADE
go
ALTER TABLE [Scat]
ADD CONSTRAINT [R_129] FOREIGN KEY ([Participant_ID]) REFERENCES [Dogs]([Participant_ID])
ON DELETE NO ACTION
ON UPDATE NO ACTION
go
ALTER TABLE [Study]
ADD CONSTRAINT [R_132] FOREIGN KEY ([RegionID]) REFERENCES [Region]([RegionID])
ON DELETE NO ACTION
ON UPDATE NO ACTION
go
ALTER TABLE [Technicians]
ADD CONSTRAINT [R_66] FOREIGN KEY ([Participant_ID]) REFERENCES [Participant]([Participant_ID])
ON DELETE CASCADE
ON UPDATE CASCADE
go
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
21 | P a g e
Insert Statementsfor InsertingData to the Database
Step:1 Create Database on the Server
Query
use master;
create database BIC06;
go
Result of the Creation
Command(s)
completed
successfully.
Step:2 Generate Database on the Server by using Physical Model of Erwin
Step:3 Load Data into Database Tables Serially
 Insert Data into Species_Type
Query
use BIC06;
INSERT INTO Species_Type VALUES ('B', 113.0, 'Black Bear');
INSERT INTO Species_Type VALUES ('G', 142.0, 'Grizzly Bear');
INSERT INTO Species_Type VALUES ('U', 0, 'Undetermined');
Go
Result of the Insert
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
 Insert Data into Status
Query
use BIC06;
INSERT INTO Status VALUES (1, 'Sample-Exists');
INSERT INTO Status VALUES (0, 'Sample-Used');
Go
Result of the Insert
(1 row(s) affected)
(1 row(s) affected)
 Insert Data into Classification
Query
use BIC06;
INSERT INTO Classification VALUES ('T', 'Telemetry');
INSERT INTO Classification VALUES ('H', 'Hair Snag');
INSERT INTO Classification VALUES ('S', 'Scat');
Go
Result of the Insert
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
 Insert Data into Participant
Query
use BIC06;
INSERT INTO Participant VALUES ('P2001', 'Bill Brown',NULL, '2014-02-14');
INSERT INTO Participant VALUES ('P2004', 'Jane Smith',NULL, '2014-02-14');
INSERT INTO Participant VALUES ('P2036', 'Frank Martin', '2014-01-01', '2012-
08-15');
INSERT INTO Participant VALUES ('P2045', 'Anne Dough', NULL,'2013-06-12');
INSERT INTO Participant VALUES ('P2046', 'Mike Green', NULL, '2012-10-28');
INSERT INTO Participant VALUES ('D0004', 'Max', NULL,'2014-06-01');
INSERT INTO Participant VALUES ('D0008', 'Sampson', NULL,'2014-02-05');
INSERT INTO Participant VALUES ('D0013', 'Cindy', '2014-12-20','2013-12-10');
INSERT INTO Participant VALUES ('D0022', 'Rover', NULL,'2014-05-20');
INSERT INTO Participant VALUES ('P0000', 'Bob', NULL, NULL);
INSERT INTO Participant VALUES ('P0101', 'Sam', NULL, NULL);
INSERT INTO Participant VALUES ('P0102', 'Mary', NULL, NULL);
INSERT INTO Participant VALUES ('P0103', 'Fred Foreman', NULL, NULL);
Go
Result of the Insert
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
 Insert Data into Manager
Query
use BIC06;
INSERT INTO Manager VALUES ('P0101', NULL);
INSERT INTO Manager VALUES ('P0102', NULL);
INSERT INTO Manager VALUES ('P0103', NULL);
Go
Result of the Insert
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
22 | P a g e
 Insert Data into Director
Query
use BIC06;
INSERT INTO Director Values ('P0000', NULL);
Go
Result of the Insert
(1 row(s) affected)
 Insert Data into Dogs
Query
use BIC06;
INSERT INTO Dogs VALUES ('D0004', 4);
INSERT INTO Dogs VALUES ('D0013', 2);
INSERT INTO Dogs VALUES ('D0022', 2);
INSERT INTO Dogs VALUES ('D0008', 2);
Go
Result of the Insert
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
 Insert Data into Technicians
Query
use BIC06;
INSERT INTO Technicians VALUES ('P2001');
INSERT INTO Technicians VALUES ('P2004');
INSERT INTO Technicians VALUES ('P2036');
INSERT INTO Technicians VALUES ('P2045');
INSERT INTO Technicians VALUES ('P2046');
Go
Result of the Insert
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
 Insert Data into Region
Query
use BIC06;
INSERT INTO Region VALUES ('NR', 'North Region', '9X9', 'P0101');
INSERT INTO Region VALUES ('CR', 'Central Region', '9X9','P0102' );
INSERT INTO Region VALUES ('SR', 'South Region', '5X5','P0103' );
Go
Result of the Insert
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
 Insert Data into Study
Query
use BIC06;
INSERT INTO Study VALUES ('N14', 'North 2014', 'NR');
INSERT INTO Study VALUES ('S14', 'South 2014', 'SR');
INSERT INTO Study VALUES ('C14', 'Central 2014', 'CR');
INSERT INTO Study VALUES ('C15', 'Central 2015', 'CR');
Go
Result of the Insert
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
 Insert Data into Animal
Query
use BIC06;
INSERT INTO Animal VALUES (42, 'M', 'B', 'N14');
INSERT INTO Animal VALUES (59, 'F', 'B', 'C15');
INSERT INTO Animal VALUES (89, 'F', 'B', 'S14');
INSERT INTO Animal VALUES (59, 'M', 'B', 'C14');
INSERT INTO Animal VALUES (113, 'F', 'G', 'C14');
INSERT INTO Animal VALUES (50, 'U', 'B', 'C15');
INSERT INTO Animal VALUES (118, 'F', 'B', 'N14');
INSERT INTO Animal VALUES (112, 'M', 'G', 'C15');
INSERT INTO Animal VALUES (66, 'F', 'G', 'C14');
INSERT INTO Animal VALUES (66, 'U', 'U', 'N14');
INSERT INTO Animal VALUES (66, 'M', 'B', 'S14');
INSERT INTO Animal VALUES (113, 'F', 'G', 'N14');
INSERT INTO Animal VALUES (63, 'M', 'B', 'S14');
INSERT INTO Animal VALUES (114, 'F', 'G', 'C14');
Go
Result of the Insert
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
23 | P a g e
 Insert Data into Sample_Details
Query
use BIC06;
INSERT INTO Sample_Details VALUES (17, '2014/07', 'S',1,'05:8:3',42,'N14');
INSERT INTO Sample_Details VALUES (22, '2014/11','H',1,'93:2:4',89, 'S14');
INSERT INTO Sample_Details VALUES (44, '2014/09', 'T',0,'32:1:9',59, 'C14');
INSERT INTO Sample_Details VALUES (45, '2015/10', 'H',0,'40:1:1',113,'C14');
INSERT INTO Sample_Details VALUES (47, '2014/09', 'T',0,'41:2:3',59,'C14');
INSERT INTO Sample_Details VALUES (48, '2015/09', 'S',1,'34:4:4', 59, 'C15');
INSERT INTO Sample_Details VALUES (56, '2015/07', 'S',1,'40:1:1',50,'C15');
INSERT INTO Sample_Details VALUES (59, '2014/06', 'S',1,'07:1:2',118,'N14');
INSERT INTO Sample_Details VALUES (79, '2014/07', 'S',1,'32:5:5',112,'C15');
INSERT INTO Sample_Details VALUES (82, '2014/11', 'T',0,'31:5:8',66,'C14');
INSERT INTO Sample_Details VALUES (100, '2014/07', 'S',0,'01:1:9',66,'N14');
INSERT INTO Sample_Details VALUES (68, '2014/07', 'H',0,'80:3:2',66,'S14');
INSERT INTO Sample_Details VALUES (27, '2014/08', 'S',1,'15:2:6',42,'N14');
INSERT INTO Sample_Details VALUES (11, '2014/07', 'S',0,'19:4:7',113,'N14');
INSERT INTO Sample_Details VALUES (45, '2014/07', 'S',0,'90:3:4',63,'S14');
INSERT INTO Sample_Details VALUES (17, '2014/10', 'T',1,'38:4:1',114,'C14');
INSERT INTO Sample_Details VALUES (18, '2014/10', 'S',1,'38:4:1',114,'C14');
Go
Result of the Insert
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
 Insert Data into Scat
Query
use BIC06;
INSERT INTO Scat VALUES ('S',109,17, 'D0004');
INSERT INTO Scat VALUES ('S',100,48, 'D0013');
INSERT INTO Scat VALUES ('S',103.5,56, 'D0004');
INSERT INTO Scat VALUES ('S',120,59, 'D0022');
INSERT INTO Scat VALUES ('S',135,79, 'D0004');
INSERT INTO Scat VALUES ('S',NULL,100, 'D0022');
INSERT INTO Scat VALUES ('S',115,27, 'D0008');
INSERT INTO Scat VALUES ('S',135,11, 'D0008');
INSERT INTO Scat VALUES ('S',117,45, 'D0013');
INSERT INTO Scat VALUES ('S',150,18, 'D0004');
Go
Result of the Insert
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
 Insert Data into Other_Tracking__Methods
Query
use BIC06;
INSERT INTO Other_Tracking__Methods VALUES (22, 'H','P2045');
INSERT INTO Other_Tracking__Methods VALUES (44, 'T','P2001');
INSERT INTO Other_Tracking__Methods VALUES (45, 'H','P2046');
INSERT INTO Other_Tracking__Methods VALUES (47, 'T','P2045');
INSERT INTO Other_Tracking__Methods VALUES (82, 'T','P2045');
INSERT INTO Other_Tracking__Methods VALUES (68, 'H','P2004');
INSERT INTO Other_Tracking__Methods VALUES (17, 'T','P2004');
Go
Result of the Insert
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
24 | P a g e
Validationof the InsertedData
 Select on Species_Code
Query:
use BIC06;
select Species_Code, Average_PHT, Species_Name from [dbo].[Species_Type];
Go
Result:
Species_Code Average_PHT Species_Name
------------ --------------------------------------- --------------------
B 113 Black Bear
G 142 Grizzly Bear
U 0 Undetermined
(3 row(s) affected)
 Select on Status
Query:
use BIC06;
select [Status], Status_Name from [dbo].[Status];
Go
Result:
Status Status_Name
------------------ ----------------------------------------
0 Sample-Used
1 Sample-Exists
(2 row(s) affected)
 Select on Classification
Query:
use BIC06;
select Class_ID, Classification_Name from [dbo].[Classification]
Go
Result:
Class_ID Classification_Name
------------------ -------------------
H Hair Snag
S Scat
T Telemetry
(3 row(s) affected)
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
25 | P a g e
 Select on Participant
Query:
use BIC06;
select [Participant_ID],
Participant_Name ,isNULL(convert(char(12),End_Date),'')as End_Date,
isNULL(convert(char(12),[Start_Date]),' ')as [Start_Date] from [dbo].[Participant];
Go
Result:
Participant_ID Participant_Name End_Date Start_Date
-------------------- ------------------------ ------------ ------------
D0004 Max 2014-06-01
D0008 Sampson 2014-02-05
D0013 Cindy 2014-12-20 2013-12-10
D0022 Rover 2014-05-20
P0000 Bob
P0101 Sam
P0102 Mary
P0103 Fred Foreman
P2001 Bill Brown 2014-02-14
P2004 Jane Smith 2014-02-14
P2036 Frank Martin 2014-01-01 2012-08-15
P2045 Anne Dough 2013-06-12
P2046 Mike Green 2012-10-28
(13 row(s) affected)
 Select on Manager
Query:
use BIC06;
select Participant_ID, isNULL(convert(char(12),Last_Access_Log),'')as Last_Access_Log from
[dbo].[Manager];
Go
Result:
Participant_ID Last_Access_Log
-------------------- ---------------
P0101
P0102
P0103
(3 row(s) affected)
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
26 | P a g e
 Select on Director
Query:
use BIC06;
select Participant_ID, isNULL(convert(char(12),Next_Inspection_Date),'')as Next_Inspection_Date from
[dbo].[Director];
Go
Result:
Participant_ID Next_Inspection_Date
-------------------- --------------------
P0000
(1 row(s) affected)
 Select on Dogs
Query:
use BIC06;
select Participant_ID, Number_Samples from [dbo].[Dogs];
Go
Result:
Participant_ID Number_Samples
-------------------- --------------
D0004 4
D0008 2
D0013 2
D0022 2
(4 row(s) affected)
 Select on Technicians
Query:
use BIC06;
select Participant_ID from [dbo].[Technicians];
Go
Result:
Participant_ID
--------------------
P2001
P2004
P2036
P2045
P2046
(5 row(s) affected)
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
27 | P a g e
 Select on Region
Query:
use BIC06;
select RegionID, Region_Name, Size, Participant_ID from [dbo].[Region];
Go
Result:
RegionID Region_Name Size Participant_ID
------------------ ------------------ ------------------ --------------------
CR Central Region 9X9 P0102
NR North Region 9X9 P0101
SR South Region 5X5 P0103
(3 row(s) affected)
 Select on Study
Query:
use BIC06;
select Study_ID, Study_Name, RegionID from [dbo].[Study];
Go
Result:
Study_ID Study_Name RegionID
-------- ------------------------ ------------------
C14 Central 2014 CR
C15 Central 2015 CR
N14 North 2014 NR
S14 South 2014 SR
(4 row(s) affected)
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
28 | P a g e
 Select on Animal
Query:
use BIC06;
select Animal_Number, Sex, Species_Code, Study_ID from [dbo].[Animal];
Go
Result:
Animal_Number Sex Species_Code Study_ID
------------- ------------------ ------------ --------
42 M B N14
50 U B C15
59 M B C14
59 F B C15
63 M B S14
66 F G C14
66 U U N14
66 M B S14
89 F B S14
112 M G C15
113 F G C14
113 F G N14
114 F G C14
118 F B N14
(14 row(s) affected)
 Select on Other_Tracking__Methods
Query:
use BIC06;
select Sample_Number, Class_ID, Participant_ID from [dbo].[Other_Tracking__Methods]
Go
Result:
Sample_Number Class_ID Participant_ID
---------------------- ------------------ --------------------
17 T P2004
22 H P2045
44 T P2001
45 H P2046
47 T P2045
68 H P2004
82 T P2045
(7 row(s) affected)
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
29 | P a g e
 Select on Sample_Details
Query:
use BIC06;
select Sample_Number, Sample_Date, Class_ID, Status, Location, Animal_Number, Study_ID from
[dbo].[Sample_Details];
Go
Result:
Sample_Number Sample_Date Class_ID Status Location Animal_Number Study_ID
------------------ --------------------- ------------ ---------- ------------ ------------- --------
11 2014/07 S 0 19:4:7 113 N14
17 2014/07 S 1 05:8:3 42 N14
17 2014/10 T 1 38:4:1 114 C14
18 2014/10 S 1 38:4:1 114 C14
22 2014/11 H 1 93:2:4 89 S14
27 2014/08 S 1 15:2:6 42 N14
44 2014/09 T 0 32:1:9 59 C14
45 2015/10 H 0 40:1:1 113 C14
45 2014/07 S 0 90:3:4 63 S14
47 2014/09 T 0 41:2:3 59 C14
48 2015/09 S 1 34:4:4 59 C15
56 2015/07 S 1 40:1:1 50 C15
59 2014/06 S 1 07:1:2 118 N14
68 2014/07 H 0 80:3:2 66 S14
79 2014/07 S 1 32:5:5 112 C15
82 2014/11 T 0 31:5:8 66 C14
100 2014/07 S 0 01:1:9 66 N14
(17 row(s) affected)
 Select on Scat
Query:
use BIC06;
select Class_ID, isNULL(convert(char(12),PHT_Value),'')as PHT_Value , Sample_Number, Participant_ID
from [dbo].[Scat];
Go
Result:
Class_ID PHT_Value Sample_Number Participant_ID
------------------ ------------ ---------------------- --------------------
S 135 11 D0008
S 109 17 D0004
S 150 18 D0004
S 115 27 D0008
S 117 45 D0013
S 100 48 D0013
S 103.5 56 D0004
S 120 59 D0022
S 135 79 D0004
S 100 D0022
(10 row(s) affected)
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
30 | P a g e
DesignRevolutions
Logical Model Version:1
Physical Model Version:1
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
31 | P a g e
Logical Model Version:2
Physical Model Version:2
BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06
32 | P a g e
Explanation for ChangingPreviousVersionsofLDM’s and PDM’s
ChangesMade in LDM
 The Previousmodel hadsub-typeslikeDirectorandManagerconnectedtoeach otherwhichwasnot requiredas
directorcan getaccess to Manager’slast accesslog fromthe participanttable,Howeveritisimportanttoconnect
Manager to RegionTable aseach managerhas regionshe/she manages
 One of the majorchangeswas connectingsub-typesdogsandtechnicianstotheirrespectivesample classification
insteadof connectingSample Detailstable toParticipant,thiswasnecessaryasParticipantTable containsDirector,
Manager sub-typestoowhowill have nosamplesassuchassignedtothem
 Therefore itwaseasierif we connecteddogstoScat table as dogsonlyworkwithScat samplesandTechnicianswork
withotherSampleslike HairandTelemetry
 ClassificationandStatustableswere addedaswe didnothave ClassificationName andStatusName justthe fields
whichgave us short-forms
 Locationdetailsare betterin Sample_Detailstable asthiswill be ameasure of where the sample wasfound
 Class_IDisnot requiredinSpecies_Type table astheydonotdetermine eachotherandare not required
 Insteadof Sample_DetailsdeterminingAnimal,Animalentityshouldbe referencedinsample forease of knowing
whichsample belongstowhichanimal,Also accordingtoFD’sSample NumberdeterminesAnimal_Numberand
Study_ID
 PHT_Value isdeterminedonlyby Sample_Numberandfromtopdownapproachit can be saidthat onlyscat
informationcanhelpusindetermining the PHT_Value
ChangesMade in PDM
 SQL needsDD/MM/YY format andSample_Date onlyhasMM/YY formattherefore itshouldbe charformat instead
of date
 ChangedtexttoChar for ease of Querying
 ChangedAverage_PHTtodecimal because of data_type errorfromErwin

More Related Content

Similar to BICFinal06

Detection of malicious attacks by Meta classification algorithms
Detection of malicious attacks by Meta classification algorithmsDetection of malicious attacks by Meta classification algorithms
Detection of malicious attacks by Meta classification algorithmsEswar Publications
 
Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015Johann de Boer
 
Splunk Enterpise for Information Security Hands-On
Splunk Enterpise for Information Security Hands-OnSplunk Enterpise for Information Security Hands-On
Splunk Enterpise for Information Security Hands-OnSplunk
 
About decision tree induction which helps in learning
About decision tree induction  which helps in learningAbout decision tree induction  which helps in learning
About decision tree induction which helps in learningGReshma10
 
Grill at bigdata-cloud conf
Grill at bigdata-cloud confGrill at bigdata-cloud conf
Grill at bigdata-cloud confamarsri
 
Writing efficient sql
Writing efficient sqlWriting efficient sql
Writing efficient sqlj9soto
 
Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Miguel González-Fierro
 
Kudler has plenty of room to increase sales while controlling cost.docx
Kudler has plenty of room to increase sales while controlling cost.docxKudler has plenty of room to increase sales while controlling cost.docx
Kudler has plenty of room to increase sales while controlling cost.docxDIPESH30
 
Rakuten Technology Conference 2017 A Distributed SQL Database For Data Analy...
Rakuten Technology Conference 2017 A Distributed SQL Database  For Data Analy...Rakuten Technology Conference 2017 A Distributed SQL Database  For Data Analy...
Rakuten Technology Conference 2017 A Distributed SQL Database For Data Analy...Rakuten Group, Inc.
 
Personal Research Overview presented at the KU-NAIST Research Meeting
Personal Research Overview presented at the KU-NAIST Research MeetingPersonal Research Overview presented at the KU-NAIST Research Meeting
Personal Research Overview presented at the KU-NAIST Research MeetingChawanat Nakasan
 
Iterative Methodology for Personalization Models Optimization
 Iterative Methodology for Personalization Models Optimization Iterative Methodology for Personalization Models Optimization
Iterative Methodology for Personalization Models OptimizationSonya Liberman
 
Advanced tips for making Oracle databases faster
Advanced tips for making Oracle databases fasterAdvanced tips for making Oracle databases faster
Advanced tips for making Oracle databases fasterSolarWinds
 
Advanced SQL - Quebec 2014
Advanced SQL - Quebec 2014Advanced SQL - Quebec 2014
Advanced SQL - Quebec 2014Connor McDonald
 
Virtual Knowledge Graphs for Federated Log Analysis
Virtual Knowledge Graphs for Federated Log AnalysisVirtual Knowledge Graphs for Federated Log Analysis
Virtual Knowledge Graphs for Federated Log AnalysisKabul Kurniawan
 
hydrogenbigdataanalysis
hydrogenbigdataanalysishydrogenbigdataanalysis
hydrogenbigdataanalysisManvi Chandra
 
Application of K-Means Clustering Algorithm for Classification of NBA Guards
Application of K-Means Clustering Algorithm for Classification of NBA GuardsApplication of K-Means Clustering Algorithm for Classification of NBA Guards
Application of K-Means Clustering Algorithm for Classification of NBA GuardsEditor IJCATR
 
Machine Learning: Classification Concepts (Part 1)
Machine Learning: Classification Concepts (Part 1)Machine Learning: Classification Concepts (Part 1)
Machine Learning: Classification Concepts (Part 1)Daniel Chan
 

Similar to BICFinal06 (20)

Detection of malicious attacks by Meta classification algorithms
Detection of malicious attacks by Meta classification algorithmsDetection of malicious attacks by Meta classification algorithms
Detection of malicious attacks by Meta classification algorithms
 
Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015
 
Splunk Enterpise for Information Security Hands-On
Splunk Enterpise for Information Security Hands-OnSplunk Enterpise for Information Security Hands-On
Splunk Enterpise for Information Security Hands-On
 
About decision tree induction which helps in learning
About decision tree induction  which helps in learningAbout decision tree induction  which helps in learning
About decision tree induction which helps in learning
 
Grill at bigdata-cloud conf
Grill at bigdata-cloud confGrill at bigdata-cloud conf
Grill at bigdata-cloud conf
 
AIRS2016
AIRS2016AIRS2016
AIRS2016
 
Writing efficient sql
Writing efficient sqlWriting efficient sql
Writing efficient sql
 
Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...
 
Kudler has plenty of room to increase sales while controlling cost.docx
Kudler has plenty of room to increase sales while controlling cost.docxKudler has plenty of room to increase sales while controlling cost.docx
Kudler has plenty of room to increase sales while controlling cost.docx
 
Rakuten Technology Conference 2017 A Distributed SQL Database For Data Analy...
Rakuten Technology Conference 2017 A Distributed SQL Database  For Data Analy...Rakuten Technology Conference 2017 A Distributed SQL Database  For Data Analy...
Rakuten Technology Conference 2017 A Distributed SQL Database For Data Analy...
 
Personal Research Overview presented at the KU-NAIST Research Meeting
Personal Research Overview presented at the KU-NAIST Research MeetingPersonal Research Overview presented at the KU-NAIST Research Meeting
Personal Research Overview presented at the KU-NAIST Research Meeting
 
Iterative Methodology for Personalization Models Optimization
 Iterative Methodology for Personalization Models Optimization Iterative Methodology for Personalization Models Optimization
Iterative Methodology for Personalization Models Optimization
 
Benchmarking_ML_Tools
Benchmarking_ML_ToolsBenchmarking_ML_Tools
Benchmarking_ML_Tools
 
Advanced tips for making Oracle databases faster
Advanced tips for making Oracle databases fasterAdvanced tips for making Oracle databases faster
Advanced tips for making Oracle databases faster
 
Advanced SQL - Quebec 2014
Advanced SQL - Quebec 2014Advanced SQL - Quebec 2014
Advanced SQL - Quebec 2014
 
Virtual Knowledge Graphs for Federated Log Analysis
Virtual Knowledge Graphs for Federated Log AnalysisVirtual Knowledge Graphs for Federated Log Analysis
Virtual Knowledge Graphs for Federated Log Analysis
 
hydrogenbigdataanalysis
hydrogenbigdataanalysishydrogenbigdataanalysis
hydrogenbigdataanalysis
 
Sbst2018 contest2018
Sbst2018 contest2018Sbst2018 contest2018
Sbst2018 contest2018
 
Application of K-Means Clustering Algorithm for Classification of NBA Guards
Application of K-Means Clustering Algorithm for Classification of NBA GuardsApplication of K-Means Clustering Algorithm for Classification of NBA Guards
Application of K-Means Clustering Algorithm for Classification of NBA Guards
 
Machine Learning: Classification Concepts (Part 1)
Machine Learning: Classification Concepts (Part 1)Machine Learning: Classification Concepts (Part 1)
Machine Learning: Classification Concepts (Part 1)
 

More from Shreya Chakrabarti

Certificate in google analytics beginners
Certificate in google analytics   beginnersCertificate in google analytics   beginners
Certificate in google analytics beginnersShreya Chakrabarti
 
Citizen Data Scientist : Marketing perspective Certification
Citizen Data Scientist : Marketing perspective CertificationCitizen Data Scientist : Marketing perspective Certification
Citizen Data Scientist : Marketing perspective CertificationShreya Chakrabarti
 
Microsoft Virtual Academy Certificate of Completion Python
Microsoft Virtual Academy Certificate of Completion PythonMicrosoft Virtual Academy Certificate of Completion Python
Microsoft Virtual Academy Certificate of Completion PythonShreya Chakrabarti
 
Programming Languages - Functional Programming Paper
Programming Languages - Functional Programming PaperProgramming Languages - Functional Programming Paper
Programming Languages - Functional Programming PaperShreya Chakrabarti
 
Intelligent Systems - Predictive Analytics Project
Intelligent Systems - Predictive Analytics ProjectIntelligent Systems - Predictive Analytics Project
Intelligent Systems - Predictive Analytics ProjectShreya Chakrabarti
 
Survey Paper on Google Project Loon- Ballon for Everyone
Survey Paper on Google Project Loon- Ballon for EveryoneSurvey Paper on Google Project Loon- Ballon for Everyone
Survey Paper on Google Project Loon- Ballon for EveryoneShreya Chakrabarti
 
Summer Independent Study Report
Summer Independent Study ReportSummer Independent Study Report
Summer Independent Study ReportShreya Chakrabarti
 

More from Shreya Chakrabarti (11)

Certificate in google analytics beginners
Certificate in google analytics   beginnersCertificate in google analytics   beginners
Certificate in google analytics beginners
 
Citizen Data Scientist : Marketing perspective Certification
Citizen Data Scientist : Marketing perspective CertificationCitizen Data Scientist : Marketing perspective Certification
Citizen Data Scientist : Marketing perspective Certification
 
Machine Learning with MATLAB
Machine Learning with MATLABMachine Learning with MATLAB
Machine Learning with MATLAB
 
Microsoft Virtual Academy Certificate of Completion Python
Microsoft Virtual Academy Certificate of Completion PythonMicrosoft Virtual Academy Certificate of Completion Python
Microsoft Virtual Academy Certificate of Completion Python
 
Programming Languages - Functional Programming Paper
Programming Languages - Functional Programming PaperProgramming Languages - Functional Programming Paper
Programming Languages - Functional Programming Paper
 
Intelligent Systems - Predictive Analytics Project
Intelligent Systems - Predictive Analytics ProjectIntelligent Systems - Predictive Analytics Project
Intelligent Systems - Predictive Analytics Project
 
PROJECT PPT
PROJECT PPTPROJECT PPT
PROJECT PPT
 
BE Project
BE ProjectBE Project
BE Project
 
Project Loon - Final PPT
Project Loon - Final PPTProject Loon - Final PPT
Project Loon - Final PPT
 
Survey Paper on Google Project Loon- Ballon for Everyone
Survey Paper on Google Project Loon- Ballon for EveryoneSurvey Paper on Google Project Loon- Ballon for Everyone
Survey Paper on Google Project Loon- Ballon for Everyone
 
Summer Independent Study Report
Summer Independent Study ReportSummer Independent Study Report
Summer Independent Study Report
 

BICFinal06

  • 1. [DBDS DataBase Design Specialists, Inc.] “We are always 5NF” Bears in Canada Project [Final Project Report] Chakrabarti, Shreya NN: 06 Data Architect [The Document contains Final Report pertaining to Bears in Canada Project]
  • 2. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 2 | P a g e Table of Contents Topic Page  Introduction 3  ProblemStatement 3  ProposedSolution 3  Functional Dependencies 4 1. Graphical Representation 6  Design 7 1. Logical Data Model 7 2. Physical Data Model 7  Query Results 8  Memo#7 14  Appendix 16 1. Data DefinitionLanguage (DDL) for creatingrelationsin Database 16 2. Insert Statementsfor InsertingData to the Database 21 3. Validationof the InsertedData 24 4. DesignRevolutions 30 a. Logical Model Version:1 30 b. Physical Model Version:1 30 c. Logical Model Version:2 31 d. Physical Model Version:2 31  Explanation for changingPreviousLDM and PDM 32
  • 3. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 3 | P a g e Introduction The Projectwas undertakenbyauthoritiesinCanadato keeptrack of populationandhealthstatisticsof the decreasingeverincreasingBearPopulationof Canada. The projectis abouttrackingthe locationandhealthof bearsin or neara national parkin Canada.Tracking is done bythree differentmethods:telemetrytracking (aftera bearhas beencapturedandtracking device has beenattached),hairsnags(foundonbushesandtrees inthe area),andscats (animal feces) located by speciallytraineddogs. DNA datafromhair and scat samplescanbe usedtodetermine the sex of the bear and some healthdata.The Scat samplesprovide individualizeddataonthe physiological healthof that animal.The total area of the National Parkisdivided intomanyregions inwhichstudiesare beingconducted. The regionsandother detailscanbe foundinthe map alongside. ProblemStatement The existingdatasethasthe followinginconsistencies  Data Redundancy,Noproperstorage forthe data  No Categorizationof the data  No ProperData HandlingMethods The database for BIC implementedthroughthisprojectwill addressthe above identifiedProblems ProposedSolution The newdatabase wouldbe designedusingthe below steps  List of (charts of) Functional Dependencies  A relational database design(5NF) –a logical DataModel,and a correspondingPhysicalDataModel  A prototype of relational databasedesign(RDD) generatedbyErwinusingSQLServer2014  Results,fromthe prototype database,forqueries(questions) Functional Dependencies
  • 4. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 4 | P a g e Bottom Up SpeciesCode ->Average PHT Average PHT-> SpeciesCode RegionID-> Size StudyName -> RegionID StudyName -> StudyID StudyID -> StudyName StudyName -> Size StudyID -> RegionID StudyID -> Size Location-> RegionID Location-> Size Sample Number->Status ParticipantID-> NumberSamples NumberSamples ->ParticipantID ParticipantID-> Name Name -> ParticipantID Start Date -> ParticipantID ParticipantID-> Start Date Name -> NumberSamples Start Date -> NumberSamples Start Date -> Name StudyID -> Study Name ParticipantID-> NumberSamples ParticipantID-> Name ParticipantID-> Start Date SpeciesCode ->Average PHT Name
  • 5. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 5 | P a g e Top Down Approach From the enterprise statementwe have the below FD’s ParticipantID-> End Date Sample_Number->Location Animal Number,StudyID->Sex List of Tablesdeterminedfromthe FD’s  Participant->{Participant ID, Participant-Name,Start-Date,End-Date} Participant_ID– PrimaryKey  Region->{RegionID, RegionName,Size ParticipantID(F.K) } RegionID–Primary Key ParticipantID– ForeignKey  Study -> {Study ID, Study-Name,RegionID(F.K)} StudyID – PrimaryKey RegionID– ForeignKey  Classification ->{ClassID, ClassificationName} ClassID – PrimaryKey  Status-> {Status ID, StatusName} StatusID –Primary Key  SpeciesType ->{Species_Code,SpeciesName,AveragePHT} SpeciesCode –PrimaryKey  Animal ->{Animal Number,Study ID, SpeciesCode(FK),Sex} Animal Number->PrimaryKey StudyID -> PrimaryKey SpeciesCode ->ForeignKey  Sample_Details ->{Sample_Number,ClassID,StudyID(F.K),AnimalNumber(F.K),Status(F.K),Sample Date, Location} Sample Number->PrimaryKey ClassID -> Composite PrimaryKey StudyID, Animal Number,Status ->ForeignKey ClusteredPrimaryKey ClusteredPrimaryKey
  • 6. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 6 | P a g e Graphical Representation Species Code RegionID StudyName Study ID Size ClassID Average PHT PHT Value Animal Number Location Sample Date Sample Number Sex Status Participant ID Number Samples Name StartDate End Date
  • 7. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 7 | P a g e Design Logical Data Model for Bears in Canada Project Physical Data Model for Bears in Canada Project
  • 8. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 8 | P a g e Query Results (Memo:#3) 1) What isthe largestphysiological healthvalueobservedforablackbear? Query: Use BIC06; SELECT MAX(PHT_Value) as 'Largest Physiological Health Value of a black bear' FROM Scat JOIN Sample_Details on Scat.[Sample_Number] = Sample_Details.[Sample_Number] join Animal on Sample_Details.Animal_Number = Animal.Animal_Number where Species_Code = 'B'; Go Result: Largest Physiological Health Value of a black bear -------------------------------------------------- 120 Warning: Null value is eliminated by an aggregate or other SET operation. (1 row(s) affected) 2) For eachanimal,listall of itssample classificationsinchronological (date) order Query: use BIC06; select Class_ID as Classification, Animal_Number as Animal, cast(Sample_Date as nvarchar) as Sample_Date from Sample_Details group by cast(Sample_Date as nvarchar), Animal_Number, Class_ID Go Result: Classification Animal Sample_Date ------------------ ----------- ------------------- S 118 2014/06 S 42 2014/07 S 63 2014/07 H 66 2014/07 S 66 2014/07 S 112 2014/07 S 113 2014/07 S 42 2014/08 T 59 2014/09 S 114 2014/10 T 114 2014/10 T 66 2014/11 H 89 2014/11 S 50 2015/07 S 59 2015/09 H 113 2015/10 (16 row(s) affected)
  • 9. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 9 | P a g e 3) In whatregionisthe Central 2014 studyand whatsize andgrid pattern isusedon that study Query: use BIC06; Select Region_Name, Size From Region, Study Where Region.[RegionID] = Study.[RegionID] and Study_Name = 'Central 2014'; GO Result: Region_Name Size ------------------ ------------------ Central Region 9X9 (1 row(s) affected) 4) List the animalsthatare within5unitsof theiraverage physiological healthvalue Query: Use BIC06; select Animal_Number, ph as PHT_Value, Average_PHT, Species_Name from (select first.Animal_Number, ph, species_code from (select Animal_Number,avg(PHT_Value) as ph from sample_details join scat on sample_details.Sample_Number = scat.Sample_Number group by animal_number) as first join Animal as a on first.Animal_Number = a.Animal_Number group by first.animal_number, ph, species_code) as animal join species_type on animal.species_code = species_type.species_code where ph between Average_PHT- 5 and Average_PHT+5; Go Result: Animal_Number PHT_Value Average_PHT Species_Name ------------- ---------------------- --------------------------------------- -------------------- 42 112 113 Black Bear 63 117 113 Black Bear Warning: Null value is eliminated by an aggregate or other SET operation. (2 row(s) affected) 5) List the sample informationforCentral 2014 studiesmade inSeptember2014 and November2014 Query: Use BIC06; SELECT Study_Name, Sample_Number, Sample_Date, Class_ID, [Status], Location, Animal_Number FROM Sample_Details JOIN Study ON Sample_Details.Study_ID = Study.Study_ID where Study_Name = 'Central 2014' and (cast(Sample_Date as nvarchar) = '2014/09' or cast(Sample_Date as nvarchar) = '2014/11'); GO
  • 10. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 10 | P a g e Result: Study_Name Sample_Number Sample_Date Class_ID Status Location Animal_Number -------------------- ------------- -------------------- ------------------ ----------- -------- Central 2014 44 2014/09 T 0 32:1:9 59 Central 2014 47 2014/09 T 0 41:2:3 59 Central 2014 82 2014/11 T 0 31:5:8 66 (3 row(s) affected) 6) What Studieshave animalsforwhichsampleswere gatheredinJuly2014 Query: Use BIC06; SELECT Study_Name,Sample_Number,Animal_Number,Sample_Date FROM Sample_Details JOIN Study ON Sample_Details.Study_ID = Study.Study_ID JOIN Region ON Region.RegionID=Study.RegionID Where cast(Sample_Date as nvarchar) = '2014/07' GO Result: Study_Name Sample_Number Animal_Number Sample_Date -------------- ---------------------- ------------- ------------------------ North 2014 11 113 2014/07 North 2014 17 42 2014/07 South 2014 45 63 2014/07 South 2014 68 66 2014/07 Central 2015 79 112 2014/07 North 2014 100 66 2014/07 (6 row(s) affected) 7) What type of sampleswere collectedinthe South2014 Study Query: Use BIC06; SELECT Distinct Study_Name,Classification_Name FROM Study JOIN Sample_Details ON Study.Study_ID = Sample_Details.Study_ID JOIN Classification ON Sample_Details.Class_ID = Classification.Class_ID where Study_Name = 'South 2014' GO Result: Study_Name Classification_Name ------------------------------ ------------------------------ South 2014 Hair Snag South 2014 Scat (2 row(s) affected)
  • 11. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 11 | P a g e (Memo:#4) 8) Who (Name andID) managesthe Central Region? Query: Use BIC06; SELECT Region_name,Participant_Name,Region.[Participant_ID] from Region Join Participant ON Region.[Participant_ID] = Participant.[Participant_ID] Where Region_name = 'Central Region' Go Result: Region_name Participant_Name Participant_ID ------------------ ------------------------- -------------------- Central Region Mary P0102 (1 row(s) affected) 9) Who (Name andID) has access data onsouth regionsample data? Query: Use BIC06; Select P.[Participant_ID], Participant_Name from Participant AS P, Technicians AS T,Other_Tracking__Methods as OT, Sample_Details AS S,Region AS R, Study, Manager as M where (P.[Participant_ID]= OT.[Participant_ID] AND T.[Participant_ID]= OT.[Participant_ID] AND OT.Sample_Number = S.Sample_Number AND OT.Class_ID = S.Class_ID AND S.Study_ID=Study.Study_ID AND Study.RegionID=R.RegionID AND M.[Participant_ID]=R.[Participant_ID] AND R.Region_Name = 'South Region')or(P.[Participant_ID]=M.[Participant_ID] AND M.[Participant_ID]=R.[Participant_ID] AND R.Region_Name='South Region') group by P.[Participant_ID],Participant_Name; Go Result: Participant_ID Participant_Name -------------------- -------------------- P0103 Fred Foreman P2004 Jane Smith P2045 Anne Dough (3 row(s) affected) 10) How manytimeseachanimal hasbeensampled? Query: Use BIC06; select Study_ID,Animal_Number, count(Animal_Number) as "Sampled_Times" from Sample_Details Group by Animal_Number,Study_ID Go
  • 12. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 12 | P a g e Result: Study_ID Animal_Number Sampled_Times -------- -------------- ------------- C14 59 2 C14 66 1 C14 113 1 C14 114 2 C15 50 1 C15 59 1 C15 112 1 N14 42 2 N14 66 1 N14 113 1 N14 118 1 S14 63 1 S14 66 1 S14 89 1 (14 row(s) affected) 11) List SamplesanalyzedbyP2045 Query: use BIC06; select Participant_ID,Sample_Details.[Sample_Number] from Sample_Details INNER JOIN Other_Tracking__Methods ON Sample_Details.[Sample_Number]= Other_Tracking__Methods.[Sample_Number] where Participant_ID = 'P2045'; Go Result: Participant_ID Sample_Number -------------------- ---------------------- P2045 22 P2045 47 P2045 82 (3 row(s) affected) 12) List Namesof Dogsthat have workedineach study Query: use BIC06; select Distinct Participant.[Participant_ID],Participant_Name,Study_Name from Participant inner join Dogs on Dogs.[Participant_ID] = Participant.[Participant_ID] join Scat on Dogs.[Participant_ID] = Scat.[Participant_ID] join Sample_Details on Scat.Sample_Number = Sample_Details.Sample_Number join Study on Study.Study_ID = Sample_Details.Study_ID go
  • 13. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 13 | P a g e Result: Participant_ID Participant_Name Study_Name -------------------- -------------------- -------------------- D0004 Max Central 2014 D0004 Max Central 2015 D0004 Max North 2014 D0008 Sampson North 2014 D0013 Cindy Central 2014 D0013 Cindy Central 2015 D0013 Cindy South 2014 D0022 Rover North 2014 (8 row(s) affected)
  • 14. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 14 | P a g e Memo:#7 Additional Data 1. New Data from Bob 1.1. The Newdata fromBob will notbe insertedintothe table.  The firstrow has Sample_Number value asNull whichisaprimarykeyof Sample_Detailstable andwill not allowaNull Value  The SecondRow has noAnimal number whichisaprimaryKeyof Animal Table andtherefore cannotbe Null andtherefore thisrowalsowill notbe added  Althoughall the valuesforthe thirdtuple existSample Number59alreadyexistsinthe Datasetandas Sample_Numbercannotbe duplicate (PrimaryKeyConstraint) thisrow toowill notbe addedtothe database  The additionof these Tuplesisnotpossible because of PrimaryKeyConstraint  No MetadataChanges 2. InformationfromSam 2.1. There isto be a newStudyinthe central Regionso the StudyName forCentral 2016  The study can be addedeasilytothe existingdata  Thiswill require onlyone InsertstatementtoInsertthe new StudyintoStudyTable  The central regionalreadyexiststhereforeonlyone Insertstatementisrequiredtoaddthe data  SQL Querythat can be usedforthe insertisas below: use BIC06; INSERT INTO Study VALUES ('C16', 'Central 2016', 'CR'); Go  No MetadataChanges 2.2. NewStatisticshave beenmade availableandtheyshow thatthe current bestestimate forthe average PHTfor Black Bearis 115 and not 113  The update will not have anyissuesinthe design  Onlythe Average_PHTvalue inSpecies_Type wouldneedtobe updated  There isno change requiredinthe design  SQL QUERY that can be usedforthe update is as below: USE BIC06; UPDATE Species_Type SET Average_PHT= 113 WHERE Species_Code='B'; Go  No MetadataChanges
  • 15. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 15 | P a g e 3. Data Items from Bob that ‘’Look Different’’  Thisanimal can be tracked easily asthe data providedcanbe addedintothe database  As seenearlierinthe database same animal canbe tracked multiple times  Therefore thisAnimal canbe declaredinthe Animal Table andthentrackedindifferentstudiesusing differentsample Numbers  The newrow insertionwill nothave anyprimarykeyor referential keyintegrity constraint  SQL QUERY that can be usedforthe update is as below: INSERT INTO Animal VALUES (200, 'F', 'B', 'N14'); INSERT INTO Sample_Details VALUES (77, '2014/07' ,'T',1,'23:1:9',200,'N14'); INSERT INTO Sample_Details VALUES (78, '2014/07' ,'T',1,'29:1:1',200,'N14');  No MetadataChanges 4. Number ofSamplesField  The Fieldcan be droppedeasilyasitisneitherPrimarynorForeignKeyforthe dogstable  There will be metadatachange forremovingthe fieldfromthe DogsTable  SQL QUERY that can be usedforthe delete isasbelow: ALTER TABLE Dogs DROP COLUMN Number_Samples;
  • 16. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 16 | P a g e Appendix: Data DefinitionLanguage (DDL) for creatingrelationsin Database CREATE TABLE [Animal] ( [Animal_Number] int NOT NULL , [Sex] char(1) NULL , [Species_Code] char(1) NOT NULL , [Study_ID] char(3) NOT NULL ) go ALTER TABLE [Animal] ADD CONSTRAINT [XPKAnimal] PRIMARY KEY CLUSTERED ([Animal_Number] ASC,[Study_ID] ASC) go CREATE TABLE [Classification] ( [Class_ID] char(18) NOT NULL , [Classification_Name] char(18) NULL ) go ALTER TABLE [Classification] ADD CONSTRAINT [XPKClassification] PRIMARY KEY CLUSTERED ([Class_ID] ASC) go CREATE TABLE [Director] ( [Participant_ID] char(20) NOT NULL , [Next_Inspection_Date] date NULL ) go ALTER TABLE [Director] ADD CONSTRAINT [XPKDirector] PRIMARY KEY CLUSTERED ([Participant_ID] ASC) go CREATE TABLE [Dogs] ( [Participant_ID] char(20) NOT NULL , [Number_Samples] int NULL ) go ALTER TABLE [Dogs] ADD CONSTRAINT [XPKDogs] PRIMARY KEY CLUSTERED ([Participant_ID] ASC) go CREATE TABLE [Manager] ( [Participant_ID] char(20) NOT NULL , [Last_Access_Log] datetime NULL ) go ALTER TABLE [Manager] ADD CONSTRAINT [XPKManager] PRIMARY KEY CLUSTERED ([Participant_ID] ASC)
  • 17. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 17 | P a g e go CREATE TABLE [Other_Tracking__Methods] ( [Sample_Number] float(20) NOT NULL , [Class_ID] char(18) NOT NULL , [Participant_ID] char(20) NULL ) go ALTER TABLE [Other_Tracking__Methods] ADD CONSTRAINT [XPKOther_Tracking__Methods] PRIMARY KEY CLUSTERED ([Sample_Number] ASC,[Class_ID] ASC) go CREATE TABLE [Participant] ( [Participant_ID] char(20) NOT NULL , [Participant_Name] char(20) NULL , [End_Date] date NULL , [Start_Date] date NULL ) go ALTER TABLE [Participant] ADD CONSTRAINT [XPKParticipant] PRIMARY KEY CLUSTERED ([Participant_ID] ASC) go CREATE TABLE [Region] ( [RegionID] char(18) NOT NULL , [Region_Name] char(18) NULL , [Size] char(18) NULL , [Participant_ID] char(20) NULL ) go ALTER TABLE [Region] ADD CONSTRAINT [XPKRegion] PRIMARY KEY CLUSTERED ([RegionID] ASC) go CREATE TABLE [Sample_Details] ( [Sample_Number] float(20) NOT NULL , [Sample_Date] char(20) NULL , [Class_ID] char(18) NOT NULL , [Status] int NOT NULL , [Location] char(20) NULL , [Animal_Number] int NOT NULL , [Study_ID] char(3) NOT NULL ) go ALTER TABLE [Sample_Details] ADD CONSTRAINT [XPKSample_Details] PRIMARY KEY CLUSTERED ([Sample_Number] ASC,[Class_ID] ASC) go CREATE TABLE [Scat] ( [Class_ID] char(18) NOT NULL ,
  • 18. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 18 | P a g e [PHT_Value] float(20) NULL , [Sample_Number] float(20) NOT NULL , [Participant_ID] char(20) NULL ) go ALTER TABLE [Scat] ADD CONSTRAINT [XPKScat] PRIMARY KEY CLUSTERED ([Class_ID] ASC,[Sample_Number] ASC) go CREATE TABLE [Species_Type] ( [Species_Code] char(1) NOT NULL , [Average_PHT] decimal(20) NULL , [Species_Name] char(20) NULL ) go ALTER TABLE [Species_Type] ADD CONSTRAINT [XPKSpecies_Type] PRIMARY KEY CLUSTERED ([Species_Code] ASC) go CREATE TABLE [Status] ( [Status] int NOT NULL , [Status_Name] char(20) NULL ) go ALTER TABLE [Status] ADD CONSTRAINT [XPKStatus] PRIMARY KEY CLUSTERED ([Status] ASC) go CREATE TABLE [Study] ( [Study_ID] char(3) NOT NULL , [Study_Name] char(20) NULL , [RegionID] char(18) NOT NULL ) go ALTER TABLE [Study] ADD CONSTRAINT [XPKStudy] PRIMARY KEY CLUSTERED ([Study_ID] ASC) go CREATE TABLE [Technicians] ( [Participant_ID] char(20) NOT NULL ) go ALTER TABLE [Technicians] ADD CONSTRAINT [XPKTechnicians] PRIMARY KEY CLUSTERED ([Participant_ID] ASC) go ALTER TABLE [Animal] ADD CONSTRAINT [R_119] FOREIGN KEY ([Species_Code]) REFERENCES [Species_Type]([Species_Code]) ON DELETE NO ACTION ON UPDATE NO ACTION
  • 19. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 19 | P a g e go ALTER TABLE [Animal] ADD CONSTRAINT [R_120] FOREIGN KEY ([Study_ID]) REFERENCES [Study]([Study_ID]) ON DELETE NO ACTION ON UPDATE NO ACTION go ALTER TABLE [Director] ADD CONSTRAINT [R_136] FOREIGN KEY ([Participant_ID]) REFERENCES [Participant]([Participant_ID]) ON DELETE CASCADE ON UPDATE CASCADE go ALTER TABLE [Dogs] ADD CONSTRAINT [R_65] FOREIGN KEY ([Participant_ID]) REFERENCES [Participant]([Participant_ID]) ON DELETE CASCADE ON UPDATE CASCADE go ALTER TABLE [Manager] ADD CONSTRAINT [R_137] FOREIGN KEY ([Participant_ID]) REFERENCES [Participant]([Participant_ID]) ON DELETE CASCADE ON UPDATE CASCADE go ALTER TABLE [Other_Tracking__Methods] ADD CONSTRAINT [R_70] FOREIGN KEY ([Sample_Number],[Class_ID]) REFERENCES [Sample_Details]([Sample_Number],[Class_ID]) ON DELETE CASCADE ON UPDATE CASCADE go ALTER TABLE [Other_Tracking__Methods] ADD CONSTRAINT [R_131] FOREIGN KEY ([Participant_ID]) REFERENCES [Technicians]([Participant_ID]) ON DELETE NO ACTION ON UPDATE NO ACTION go ALTER TABLE [Region] ADD CONSTRAINT [R_138] FOREIGN KEY ([Participant_ID]) REFERENCES [Manager]([Participant_ID]) ON DELETE NO ACTION ON UPDATE NO ACTION go ALTER TABLE [Sample_Details] ADD CONSTRAINT [R_118] FOREIGN KEY ([Status]) REFERENCES [Status]([Status]) ON DELETE NO ACTION ON UPDATE NO ACTION go ALTER TABLE [Sample_Details] ADD CONSTRAINT [R_126] FOREIGN KEY ([Class_ID]) REFERENCES [Classification]([Class_ID]) ON DELETE NO ACTION
  • 20. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 20 | P a g e ON UPDATE NO ACTION go ALTER TABLE [Sample_Details] ADD CONSTRAINT [R_135] FOREIGN KEY ([Animal_Number],[Study_ID]) REFERENCES [Animal]([Animal_Number],[Study_ID]) ON DELETE NO ACTION ON UPDATE NO ACTION go ALTER TABLE [Scat] ADD CONSTRAINT [R_71] FOREIGN KEY ([Sample_Number],[Class_ID]) REFERENCES [Sample_Details]([Sample_Number],[Class_ID]) ON DELETE CASCADE ON UPDATE CASCADE go ALTER TABLE [Scat] ADD CONSTRAINT [R_129] FOREIGN KEY ([Participant_ID]) REFERENCES [Dogs]([Participant_ID]) ON DELETE NO ACTION ON UPDATE NO ACTION go ALTER TABLE [Study] ADD CONSTRAINT [R_132] FOREIGN KEY ([RegionID]) REFERENCES [Region]([RegionID]) ON DELETE NO ACTION ON UPDATE NO ACTION go ALTER TABLE [Technicians] ADD CONSTRAINT [R_66] FOREIGN KEY ([Participant_ID]) REFERENCES [Participant]([Participant_ID]) ON DELETE CASCADE ON UPDATE CASCADE go
  • 21. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 21 | P a g e Insert Statementsfor InsertingData to the Database Step:1 Create Database on the Server Query use master; create database BIC06; go Result of the Creation Command(s) completed successfully. Step:2 Generate Database on the Server by using Physical Model of Erwin Step:3 Load Data into Database Tables Serially  Insert Data into Species_Type Query use BIC06; INSERT INTO Species_Type VALUES ('B', 113.0, 'Black Bear'); INSERT INTO Species_Type VALUES ('G', 142.0, 'Grizzly Bear'); INSERT INTO Species_Type VALUES ('U', 0, 'Undetermined'); Go Result of the Insert (1 row(s) affected) (1 row(s) affected) (1 row(s) affected)  Insert Data into Status Query use BIC06; INSERT INTO Status VALUES (1, 'Sample-Exists'); INSERT INTO Status VALUES (0, 'Sample-Used'); Go Result of the Insert (1 row(s) affected) (1 row(s) affected)  Insert Data into Classification Query use BIC06; INSERT INTO Classification VALUES ('T', 'Telemetry'); INSERT INTO Classification VALUES ('H', 'Hair Snag'); INSERT INTO Classification VALUES ('S', 'Scat'); Go Result of the Insert (1 row(s) affected) (1 row(s) affected) (1 row(s) affected)  Insert Data into Participant Query use BIC06; INSERT INTO Participant VALUES ('P2001', 'Bill Brown',NULL, '2014-02-14'); INSERT INTO Participant VALUES ('P2004', 'Jane Smith',NULL, '2014-02-14'); INSERT INTO Participant VALUES ('P2036', 'Frank Martin', '2014-01-01', '2012- 08-15'); INSERT INTO Participant VALUES ('P2045', 'Anne Dough', NULL,'2013-06-12'); INSERT INTO Participant VALUES ('P2046', 'Mike Green', NULL, '2012-10-28'); INSERT INTO Participant VALUES ('D0004', 'Max', NULL,'2014-06-01'); INSERT INTO Participant VALUES ('D0008', 'Sampson', NULL,'2014-02-05'); INSERT INTO Participant VALUES ('D0013', 'Cindy', '2014-12-20','2013-12-10'); INSERT INTO Participant VALUES ('D0022', 'Rover', NULL,'2014-05-20'); INSERT INTO Participant VALUES ('P0000', 'Bob', NULL, NULL); INSERT INTO Participant VALUES ('P0101', 'Sam', NULL, NULL); INSERT INTO Participant VALUES ('P0102', 'Mary', NULL, NULL); INSERT INTO Participant VALUES ('P0103', 'Fred Foreman', NULL, NULL); Go Result of the Insert (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected)  Insert Data into Manager Query use BIC06; INSERT INTO Manager VALUES ('P0101', NULL); INSERT INTO Manager VALUES ('P0102', NULL); INSERT INTO Manager VALUES ('P0103', NULL); Go Result of the Insert (1 row(s) affected) (1 row(s) affected) (1 row(s) affected)
  • 22. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 22 | P a g e  Insert Data into Director Query use BIC06; INSERT INTO Director Values ('P0000', NULL); Go Result of the Insert (1 row(s) affected)  Insert Data into Dogs Query use BIC06; INSERT INTO Dogs VALUES ('D0004', 4); INSERT INTO Dogs VALUES ('D0013', 2); INSERT INTO Dogs VALUES ('D0022', 2); INSERT INTO Dogs VALUES ('D0008', 2); Go Result of the Insert (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected)  Insert Data into Technicians Query use BIC06; INSERT INTO Technicians VALUES ('P2001'); INSERT INTO Technicians VALUES ('P2004'); INSERT INTO Technicians VALUES ('P2036'); INSERT INTO Technicians VALUES ('P2045'); INSERT INTO Technicians VALUES ('P2046'); Go Result of the Insert (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected)  Insert Data into Region Query use BIC06; INSERT INTO Region VALUES ('NR', 'North Region', '9X9', 'P0101'); INSERT INTO Region VALUES ('CR', 'Central Region', '9X9','P0102' ); INSERT INTO Region VALUES ('SR', 'South Region', '5X5','P0103' ); Go Result of the Insert (1 row(s) affected) (1 row(s) affected) (1 row(s) affected)  Insert Data into Study Query use BIC06; INSERT INTO Study VALUES ('N14', 'North 2014', 'NR'); INSERT INTO Study VALUES ('S14', 'South 2014', 'SR'); INSERT INTO Study VALUES ('C14', 'Central 2014', 'CR'); INSERT INTO Study VALUES ('C15', 'Central 2015', 'CR'); Go Result of the Insert (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected)  Insert Data into Animal Query use BIC06; INSERT INTO Animal VALUES (42, 'M', 'B', 'N14'); INSERT INTO Animal VALUES (59, 'F', 'B', 'C15'); INSERT INTO Animal VALUES (89, 'F', 'B', 'S14'); INSERT INTO Animal VALUES (59, 'M', 'B', 'C14'); INSERT INTO Animal VALUES (113, 'F', 'G', 'C14'); INSERT INTO Animal VALUES (50, 'U', 'B', 'C15'); INSERT INTO Animal VALUES (118, 'F', 'B', 'N14'); INSERT INTO Animal VALUES (112, 'M', 'G', 'C15'); INSERT INTO Animal VALUES (66, 'F', 'G', 'C14'); INSERT INTO Animal VALUES (66, 'U', 'U', 'N14'); INSERT INTO Animal VALUES (66, 'M', 'B', 'S14'); INSERT INTO Animal VALUES (113, 'F', 'G', 'N14'); INSERT INTO Animal VALUES (63, 'M', 'B', 'S14'); INSERT INTO Animal VALUES (114, 'F', 'G', 'C14'); Go Result of the Insert (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected)
  • 23. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 23 | P a g e  Insert Data into Sample_Details Query use BIC06; INSERT INTO Sample_Details VALUES (17, '2014/07', 'S',1,'05:8:3',42,'N14'); INSERT INTO Sample_Details VALUES (22, '2014/11','H',1,'93:2:4',89, 'S14'); INSERT INTO Sample_Details VALUES (44, '2014/09', 'T',0,'32:1:9',59, 'C14'); INSERT INTO Sample_Details VALUES (45, '2015/10', 'H',0,'40:1:1',113,'C14'); INSERT INTO Sample_Details VALUES (47, '2014/09', 'T',0,'41:2:3',59,'C14'); INSERT INTO Sample_Details VALUES (48, '2015/09', 'S',1,'34:4:4', 59, 'C15'); INSERT INTO Sample_Details VALUES (56, '2015/07', 'S',1,'40:1:1',50,'C15'); INSERT INTO Sample_Details VALUES (59, '2014/06', 'S',1,'07:1:2',118,'N14'); INSERT INTO Sample_Details VALUES (79, '2014/07', 'S',1,'32:5:5',112,'C15'); INSERT INTO Sample_Details VALUES (82, '2014/11', 'T',0,'31:5:8',66,'C14'); INSERT INTO Sample_Details VALUES (100, '2014/07', 'S',0,'01:1:9',66,'N14'); INSERT INTO Sample_Details VALUES (68, '2014/07', 'H',0,'80:3:2',66,'S14'); INSERT INTO Sample_Details VALUES (27, '2014/08', 'S',1,'15:2:6',42,'N14'); INSERT INTO Sample_Details VALUES (11, '2014/07', 'S',0,'19:4:7',113,'N14'); INSERT INTO Sample_Details VALUES (45, '2014/07', 'S',0,'90:3:4',63,'S14'); INSERT INTO Sample_Details VALUES (17, '2014/10', 'T',1,'38:4:1',114,'C14'); INSERT INTO Sample_Details VALUES (18, '2014/10', 'S',1,'38:4:1',114,'C14'); Go Result of the Insert (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected)  Insert Data into Scat Query use BIC06; INSERT INTO Scat VALUES ('S',109,17, 'D0004'); INSERT INTO Scat VALUES ('S',100,48, 'D0013'); INSERT INTO Scat VALUES ('S',103.5,56, 'D0004'); INSERT INTO Scat VALUES ('S',120,59, 'D0022'); INSERT INTO Scat VALUES ('S',135,79, 'D0004'); INSERT INTO Scat VALUES ('S',NULL,100, 'D0022'); INSERT INTO Scat VALUES ('S',115,27, 'D0008'); INSERT INTO Scat VALUES ('S',135,11, 'D0008'); INSERT INTO Scat VALUES ('S',117,45, 'D0013'); INSERT INTO Scat VALUES ('S',150,18, 'D0004'); Go Result of the Insert (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected)  Insert Data into Other_Tracking__Methods Query use BIC06; INSERT INTO Other_Tracking__Methods VALUES (22, 'H','P2045'); INSERT INTO Other_Tracking__Methods VALUES (44, 'T','P2001'); INSERT INTO Other_Tracking__Methods VALUES (45, 'H','P2046'); INSERT INTO Other_Tracking__Methods VALUES (47, 'T','P2045'); INSERT INTO Other_Tracking__Methods VALUES (82, 'T','P2045'); INSERT INTO Other_Tracking__Methods VALUES (68, 'H','P2004'); INSERT INTO Other_Tracking__Methods VALUES (17, 'T','P2004'); Go Result of the Insert (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected) (1 row(s) affected)
  • 24. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 24 | P a g e Validationof the InsertedData  Select on Species_Code Query: use BIC06; select Species_Code, Average_PHT, Species_Name from [dbo].[Species_Type]; Go Result: Species_Code Average_PHT Species_Name ------------ --------------------------------------- -------------------- B 113 Black Bear G 142 Grizzly Bear U 0 Undetermined (3 row(s) affected)  Select on Status Query: use BIC06; select [Status], Status_Name from [dbo].[Status]; Go Result: Status Status_Name ------------------ ---------------------------------------- 0 Sample-Used 1 Sample-Exists (2 row(s) affected)  Select on Classification Query: use BIC06; select Class_ID, Classification_Name from [dbo].[Classification] Go Result: Class_ID Classification_Name ------------------ ------------------- H Hair Snag S Scat T Telemetry (3 row(s) affected)
  • 25. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 25 | P a g e  Select on Participant Query: use BIC06; select [Participant_ID], Participant_Name ,isNULL(convert(char(12),End_Date),'')as End_Date, isNULL(convert(char(12),[Start_Date]),' ')as [Start_Date] from [dbo].[Participant]; Go Result: Participant_ID Participant_Name End_Date Start_Date -------------------- ------------------------ ------------ ------------ D0004 Max 2014-06-01 D0008 Sampson 2014-02-05 D0013 Cindy 2014-12-20 2013-12-10 D0022 Rover 2014-05-20 P0000 Bob P0101 Sam P0102 Mary P0103 Fred Foreman P2001 Bill Brown 2014-02-14 P2004 Jane Smith 2014-02-14 P2036 Frank Martin 2014-01-01 2012-08-15 P2045 Anne Dough 2013-06-12 P2046 Mike Green 2012-10-28 (13 row(s) affected)  Select on Manager Query: use BIC06; select Participant_ID, isNULL(convert(char(12),Last_Access_Log),'')as Last_Access_Log from [dbo].[Manager]; Go Result: Participant_ID Last_Access_Log -------------------- --------------- P0101 P0102 P0103 (3 row(s) affected)
  • 26. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 26 | P a g e  Select on Director Query: use BIC06; select Participant_ID, isNULL(convert(char(12),Next_Inspection_Date),'')as Next_Inspection_Date from [dbo].[Director]; Go Result: Participant_ID Next_Inspection_Date -------------------- -------------------- P0000 (1 row(s) affected)  Select on Dogs Query: use BIC06; select Participant_ID, Number_Samples from [dbo].[Dogs]; Go Result: Participant_ID Number_Samples -------------------- -------------- D0004 4 D0008 2 D0013 2 D0022 2 (4 row(s) affected)  Select on Technicians Query: use BIC06; select Participant_ID from [dbo].[Technicians]; Go Result: Participant_ID -------------------- P2001 P2004 P2036 P2045 P2046 (5 row(s) affected)
  • 27. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 27 | P a g e  Select on Region Query: use BIC06; select RegionID, Region_Name, Size, Participant_ID from [dbo].[Region]; Go Result: RegionID Region_Name Size Participant_ID ------------------ ------------------ ------------------ -------------------- CR Central Region 9X9 P0102 NR North Region 9X9 P0101 SR South Region 5X5 P0103 (3 row(s) affected)  Select on Study Query: use BIC06; select Study_ID, Study_Name, RegionID from [dbo].[Study]; Go Result: Study_ID Study_Name RegionID -------- ------------------------ ------------------ C14 Central 2014 CR C15 Central 2015 CR N14 North 2014 NR S14 South 2014 SR (4 row(s) affected)
  • 28. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 28 | P a g e  Select on Animal Query: use BIC06; select Animal_Number, Sex, Species_Code, Study_ID from [dbo].[Animal]; Go Result: Animal_Number Sex Species_Code Study_ID ------------- ------------------ ------------ -------- 42 M B N14 50 U B C15 59 M B C14 59 F B C15 63 M B S14 66 F G C14 66 U U N14 66 M B S14 89 F B S14 112 M G C15 113 F G C14 113 F G N14 114 F G C14 118 F B N14 (14 row(s) affected)  Select on Other_Tracking__Methods Query: use BIC06; select Sample_Number, Class_ID, Participant_ID from [dbo].[Other_Tracking__Methods] Go Result: Sample_Number Class_ID Participant_ID ---------------------- ------------------ -------------------- 17 T P2004 22 H P2045 44 T P2001 45 H P2046 47 T P2045 68 H P2004 82 T P2045 (7 row(s) affected)
  • 29. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 29 | P a g e  Select on Sample_Details Query: use BIC06; select Sample_Number, Sample_Date, Class_ID, Status, Location, Animal_Number, Study_ID from [dbo].[Sample_Details]; Go Result: Sample_Number Sample_Date Class_ID Status Location Animal_Number Study_ID ------------------ --------------------- ------------ ---------- ------------ ------------- -------- 11 2014/07 S 0 19:4:7 113 N14 17 2014/07 S 1 05:8:3 42 N14 17 2014/10 T 1 38:4:1 114 C14 18 2014/10 S 1 38:4:1 114 C14 22 2014/11 H 1 93:2:4 89 S14 27 2014/08 S 1 15:2:6 42 N14 44 2014/09 T 0 32:1:9 59 C14 45 2015/10 H 0 40:1:1 113 C14 45 2014/07 S 0 90:3:4 63 S14 47 2014/09 T 0 41:2:3 59 C14 48 2015/09 S 1 34:4:4 59 C15 56 2015/07 S 1 40:1:1 50 C15 59 2014/06 S 1 07:1:2 118 N14 68 2014/07 H 0 80:3:2 66 S14 79 2014/07 S 1 32:5:5 112 C15 82 2014/11 T 0 31:5:8 66 C14 100 2014/07 S 0 01:1:9 66 N14 (17 row(s) affected)  Select on Scat Query: use BIC06; select Class_ID, isNULL(convert(char(12),PHT_Value),'')as PHT_Value , Sample_Number, Participant_ID from [dbo].[Scat]; Go Result: Class_ID PHT_Value Sample_Number Participant_ID ------------------ ------------ ---------------------- -------------------- S 135 11 D0008 S 109 17 D0004 S 150 18 D0004 S 115 27 D0008 S 117 45 D0013 S 100 48 D0013 S 103.5 56 D0004 S 120 59 D0022 S 135 79 D0004 S 100 D0022 (10 row(s) affected)
  • 30. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 30 | P a g e DesignRevolutions Logical Model Version:1 Physical Model Version:1
  • 31. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 31 | P a g e Logical Model Version:2 Physical Model Version:2
  • 32. BIC-Final Project Report CSCI 54100 Chakrabarti,ShreyaNN:06 32 | P a g e Explanation for ChangingPreviousVersionsofLDM’s and PDM’s ChangesMade in LDM  The Previousmodel hadsub-typeslikeDirectorandManagerconnectedtoeach otherwhichwasnot requiredas directorcan getaccess to Manager’slast accesslog fromthe participanttable,Howeveritisimportanttoconnect Manager to RegionTable aseach managerhas regionshe/she manages  One of the majorchangeswas connectingsub-typesdogsandtechnicianstotheirrespectivesample classification insteadof connectingSample Detailstable toParticipant,thiswasnecessaryasParticipantTable containsDirector, Manager sub-typestoowhowill have nosamplesassuchassignedtothem  Therefore itwaseasierif we connecteddogstoScat table as dogsonlyworkwithScat samplesandTechnicianswork withotherSampleslike HairandTelemetry  ClassificationandStatustableswere addedaswe didnothave ClassificationName andStatusName justthe fields whichgave us short-forms  Locationdetailsare betterin Sample_Detailstable asthiswill be ameasure of where the sample wasfound  Class_IDisnot requiredinSpecies_Type table astheydonotdetermine eachotherandare not required  Insteadof Sample_DetailsdeterminingAnimal,Animalentityshouldbe referencedinsample forease of knowing whichsample belongstowhichanimal,Also accordingtoFD’sSample NumberdeterminesAnimal_Numberand Study_ID  PHT_Value isdeterminedonlyby Sample_Numberandfromtopdownapproachit can be saidthat onlyscat informationcanhelpusindetermining the PHT_Value ChangesMade in PDM  SQL needsDD/MM/YY format andSample_Date onlyhasMM/YY formattherefore itshouldbe charformat instead of date  ChangedtexttoChar for ease of Querying  ChangedAverage_PHTtodecimal because of data_type errorfromErwin