Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RED2Hunt
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathilde Marcy
RED2Hunt
Commits
8fb1d500
Commit
8fb1d500
authored
2 months ago
by
Mathilde Marcy
Browse files
Options
Downloads
Patches
Plain Diff
Upload Perfect Pet data file and data model
parent
2bd3eab7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
perfect_pet_data/perfect_pet_db_data_model.sql
+108
-0
108 additions, 0 deletions
perfect_pet_data/perfect_pet_db_data_model.sql
with
108 additions
and
0 deletions
perfect_pet_data/perfect_pet_db_data_model.sql
0 → 100644
+
108
−
0
View file @
8fb1d500
--schema = perfect_pet
-- relation doctor
-- DROP TABLE IF EXISTS perfect_pet.doctor;
CREATE
TYPE
medical_specialty
AS
ENUM
(
'surgery'
,
'general'
);
CREATE
TABLE
IF
NOT
EXISTS
perfect_pet
.
doctor
(
id_doctor
integer
NOT
NULL
,
first_name
character
varying
(
150
)
NOT
NULL
,
last_name
character
varying
(
150
)
NOT
NULL
,
specialty
medical_specialty
NOT
NULL
,
license_number
character
varying
(
15
)
NOT
NULL
,
period_start_date
DATE
NOT
NULL
,
period_end_date
DATE
DEFAULT
NULL
,
max_monthly_hours
FLOAT
DEFAULT
0
,
CONSTRAINT
doctor_pkey
PRIMARY
KEY
(
id_doctor
)
);
------------------------------------------------------------------
-- relation microchip
-- DROP TABLE IF EXISTS perfect_pet.microchip;
CREATE
TABLE
IF
NOT
EXISTS
perfect_pet
.
microchip
(
id_microchip
integer
NOT
NULL
,
number
character
varying
(
9
)
NOT
NULL
,
implant_date
DATE
NOT
NULL
,
CONSTRAINT
microchip_pkey
PRIMARY
KEY
(
id_microchip
)
);
------------------------------------------------------------------
-- relation animal
-- DROP TABLE IF EXISTS perfect_pet.animal;
CREATE
TYPE
animal_species
AS
ENUM
(
'canine'
,
'feline'
);
CREATE
TYPE
animal_gender
AS
ENUM
(
'female'
,
'male'
);
CREATE
TABLE
IF
NOT
EXISTS
perfect_pet
.
animal
(
id_animal
integer
NOT
NULL
,
species
animal_species
NOT
NULL
,
breed
character
varying
(
50
)
NOT
NULL
,
name
character
varying
(
50
)
NOT
NULL
,
id_microchip
integer
NOT
NULL
,
gender
animal_gender
NOT
NULL
,
dob
DATE
DEFAULT
NULL
,
weight
FLOAT
,
hash_id
character
varying
(
10
)
NOT
NULL
,
id_client
integer
NOT
NULL
,
CONSTRAINT
animal_pkey
PRIMARY
KEY
(
id_animal
)
);
ALTER
TABLE
perfect_pet
.
animal
ADD
CONSTRAINT
FK_animal_microchip
FOREIGN
KEY
(
id_microchip
)
REFERENCES
perfect_pet
.
microchip
(
id_microchip
)
MATCH
SIMPLE
ON
UPDATE
NO
ACTION
ON
DELETE
NO
ACTION
;
ALTER
TABLE
perfect_pet
.
animal
ADD
CONSTRAINT
FK_animal_client
FOREIGN
KEY
(
id_client
)
REFERENCES
perfect_pet
.
client
(
id_client
)
MATCH
SIMPLE
ON
UPDATE
NO
ACTION
ON
DELETE
NO
ACTION
;
------------------------------------------------------------------
--relation appointment
-- DROP TABLE IF EXISTS perfect_pet.appointment;
CREATE
TYPE
appointment_time
AS
ENUM
(
'8'
,
'9'
,
'10'
,
'11'
,
'12'
,
'13'
,
'14'
,
'15'
,
'16'
,
'17'
,
'18'
,
'19'
,
'20'
);
CREATE
TYPE
appointment_reason
AS
ENUM
(
'injured pet'
,
'initial visit'
,
'surgery'
,
'follow-up surgery'
,
'annual visit'
,
'follow up'
,
'sick pet'
,
'follow-up'
);
CREATE
TABLE
IF
NOT
EXISTS
perfect_pet
.
appointment
(
id_appointment
integer
NOT
NULL
,
id_animal
integer
NOT
NULL
,
id_doctor
integer
NOT
NULL
,
date
DATE
NOT
NULL
,
time
appointment_time
NOT
NULL
,
main_reason
appointment_reason
NOT
NULL
,
CONSTRAINT
appointment_pkey
PRIMARY
KEY
(
id_appointment
)
);
ALTER
TABLE
perfect_pet
.
appointment
ADD
CONSTRAINT
FK_appointment_animal
FOREIGN
KEY
(
id_animal
)
REFERENCES
perfect_pet
.
animal
(
id_animal
)
MATCH
SIMPLE
ON
UPDATE
NO
ACTION
ON
DELETE
NO
ACTION
;
ALTER
TABLE
perfect_pet
.
appointment
ADD
CONSTRAINT
FK_appointment_doctor
FOREIGN
KEY
(
id_doctor
)
REFERENCES
perfect_pet
.
doctor
(
id_doctor
)
MATCH
SIMPLE
ON
UPDATE
NO
ACTION
ON
DELETE
NO
ACTION
;
------------------------------------------------------------------
-- relation client
CREATE
TABLE
IF
NOT
EXISTS
perfect_pet
.
client
(
id_client
integer
NOT
NULL
,
first_name
character
varying
(
150
)
NOT
NULL
,
last_name
character
varying
(
150
)
NOT
NULL
,
city
character
varying
(
50
)
NOT
NULL
,
phone_number
character
varying
(
10
)
NOT
NULL
,
id_animal
integer
NOT
NULL
,
CONSTRAINT
client_pkey
PRIMARY
KEY
(
id_client
)
);
ALTER
TABLE
perfect_pet
.
client
ADD
CONSTRAINT
FK_client_animal
FOREIGN
KEY
(
id_animal
)
REFERENCES
perfect_pet
.
animal
(
id_animal
)
MATCH
SIMPLE
ON
UPDATE
NO
ACTION
ON
DELETE
NO
ACTION
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment