Files
dog_training/static/MySQL/90000_populate.sql

1588 lines
22 KiB
SQL

USE fetchmetrics;
-- Error Message Types
/* Existing table */
INSERT INTO fetchmetrics.CORE_Msg_Error_Type (
code
, name
, description
, is_breaking_error
)
VALUES
(
'BAD_DATA'
, 'Invalid data'
, 'Rubbish data'
, 1
)
, (
'NO_PERMISSION'
, 'No permission'
, 'Not authorised'
, 1
)
, (
'MYSQL_ERROR'
, 'MySQL error'
, 'MySQL execution error.'
, 1
)
, (
'WARNING'
, 'Warning'
, 'Non-breaking error.'
, 0
)
;
INSERT INTO fetchmetrics.CORE_File_Type (
code
, name
, is_image
)
VALUES
(
'JPG'
, 'JPG'
, 1
)
;
-- Access Levels
INSERT INTO fetchmetrics.DOG_Access_Level (
display_order
, code
, name
, priority
)
VALUES
(
1
, 'VIEW'
, 'View'
, 3
)
, (
2
, 'EDIT'
, 'Edit'
, 2
)
, (
3
, 'ADMIN'
, 'Admin'
, 1
)
, (
4
, 'NONE'
, 'None'
, 999
)
;
-- Permission Groups
INSERT INTO fetchmetrics.DOG_Permission_Group (
display_order
, code
, name
)
VALUES
(
1
, 'DOG'
, 'Dog'
)
, (
2
, 'COMPANY'
, 'Company'
)
, (
3
, 'COMMAND'
, 'Command'
)
, (
4
, 'ASSESSMENT'
, 'Assessment'
)
, (
100
, 'USER'
, 'User'
)
, (
200
, 'PROJECT_HUB'
, 'Project Hub'
)
;
-- Permissions
INSERT INTO fetchmetrics.DOG_Permission (
display_order
, code
, name
, id_permission_group
, id_access_level_required
)
VALUES
(
1
, 'DOG_VIEW'
, 'View Dog'
, 1
, 1
)
, (
2
, 'DOG_EDIT'
, 'Edit Dog'
, 1
, 2
)
, (
3
, 'DOG_ADMIN'
, 'Admin Dog'
, 1
, 3
)
, (
1
, 'COMPANY_VIEW'
, 'View Company'
, 2
, 1
)
, (
2
, 'COMPANY_EDIT'
, 'Edit Company'
, 2
, 2
)
, (
3
, 'COMPANY_ADMIN'
, 'Admin Company'
, 2
, 3
)
, (
1
, 'COMMAND_VIEW'
, 'View Command'
, 3
, 1
)
, (
2
, 'COMMAND_EDIT'
, 'Edit Command'
, 3
, 2
)
, (
3
, 'COMMAND_ADMIN'
, 'Admin Command'
, 3
, 3
)
, (
1
, 'ASSESSMENT_VIEW'
, 'View Assessment'
, 4
, 1
)
, (
2
, 'ASSESSMENT_EDIT'
, 'Edit Assessment'
, 4
, 2
)
, (
3
, 'ASSESSMENT_ADMIN'
, 'Admin Assessment'
, 4
, 3
)
, (
1
, 'USER_VIEW'
, 'View User'
, 5
, 1
)
, (
2
, 'USER_ADMIN'
, 'Admin User'
, 5
, 3
)
, (
3
, 'USER_CREATE'
, 'Create User'
, 5
, 2
)
, (
1
, 'CONTACT_FORM_ADMIN'
, 'Admin Contact Form'
, 6
, 3
)
, (
2
, 'CONTACT_FORM_CREATE'
, 'Create Contact Form'
, 6
, 4
)
;
-- Users
INSERT INTO fetchmetrics.DOG_User (
id_user_auth0
, firstname
, surname
, email
, is_super_user
, active
)
VALUES
(
'auth0|6582b95c895d09a70ba10fef' -- id_user_auth0
, 'Teddy' -- firstname
, 'Middleton-Smith' -- surname
, 'edward.middletonsmith@gmail.com' -- email
, 1 -- is_super_user
, 1 -- active
)
, (
'auth0|672659014296b7f94a9bab45' -- id_user_auth0
, 'Tierney' -- firstname
, 'Gullen' -- surname
, 'tierneybailey13@gmail.com' -- email
, 1 -- is_super_user
, 1 -- active
)
, (
NULL -- id_user_auth0
, 'Command Bot' -- firstname
, 'Bot' -- surname
, 'teddy@partsltd.co.uk' -- email
, 0 -- is_super_user
, 1 -- active
)
, (
'auth0|679cc2fe0d652a47af90d16b' -- id_user_auth0
, 'Demo' -- firstname
, 'Demo' -- surname
, 'bot@partsltd.co.uk' -- email
, 0 -- is_super_user
, 1 -- active
)
;
-- Roles
INSERT INTO fetchmetrics.DOG_Role (
display_order
, code
, name
, id_user_created_by
)
VALUES
(
1
, 'SUPER_USER'
, 'Super User'
, 1
)
, (
4
, 'CLIENT'
, 'Client'
, 1
)
, (
2
, 'COMPANY_MANAGER'
, 'Company Manager'
, 1
)
, (
3
, 'TRAINER'
, 'Trainer'
, 1
)
;
-- Role Permission link
INSERT INTO fetchmetrics.DOG_Role_Permission_Link (
id_role
, id_permission
, id_access_level
, id_user_created_by
)
VALUES
(
1
, 1
, 3
, 1
)
, (
1
, 2
, 3
, 1
)
, (
1
, 3
, 3
, 1
)
, (
1
, 4
, 3
, 1
)
, (
1
, 5
, 3
, 1
)
, (
1
, 6
, 3
, 1
)
, (
1
, 7
, 3
, 1
)
, (
1
, 8
, 3
, 1
)
, (
1
, 9
, 3
, 1
)
, (
1
, 10
, 3
, 1
)
, (
1
, 11
, 3
, 1
)
, (
1
, 12
, 3
, 1
)
, (
1
, 13
, 3
, 1
)
, (
1
, 14
, 3
, 1
)
, (
1
, 15
, 3
, 1
)
, (
1
, 16
, 3
, 1
)
, (
1
, 17
, 3
, 1
)
, (
2
, 1
, 1
, 1
)
, (
2
, 2
, 1
, 1
)
, (
2
, 3
, 1
, 1
)
, (
2
, 4
, 1
, 1
)
, (
2
, 5
, 1
, 1
)
, (
2
, 6
, 1
, 1
)
, (
2
, 7
, 1
, 1
)
, (
2
, 8
, 1
, 1
)
, (
2
, 9
, 1
, 1
)
, (
2
, 10
, 1
, 1
)
, (
2
, 11
, 1
, 1
)
, (
2
, 12
, 1
, 1
)
, (
2
, 13
, 1
, 1
)
, (
2
, 14
, 1
, 1
)
, (
2
, 15
, 1
, 1
)
, (
2
, 16
, 1
, 1
)
, (
2
, 17
, 1
, 1
)
, (
3
, 1
, 2
, 1
)
, (
3
, 2
, 2
, 1
)
, (
3
, 3
, 1
, 1
)
, (
3
, 4
, 2
, 1
)
, (
3
, 5
, 2
, 1
)
, (
3
, 6
, 1
, 1
)
, (
3
, 7
, 2
, 1
)
, (
3
, 8
, 2
, 1
)
, (
3
, 9
, 1
, 1
)
, (
3
, 10
, 2
, 1
)
, (
3
, 11
, 2
, 1
)
, (
3
, 12
, 1
, 1
)
, (
3
, 13
, 1
, 1
)
, (
3
, 14
, 1
, 1
)
, (
3
, 15
, 1
, 1
)
, (
3
, 16
, 1
, 1
)
, (
3
, 17
, 1
, 1
)
, (
4
, 1
, 1
, 1
)
, (
4
, 2
, 2
, 1
)
, (
4
, 3
, 1
, 1
)
, (
4
, 4
, 1
, 1
)
, (
4
, 5
, 1
, 1
)
, (
4
, 6
, 1
, 1
)
, (
4
, 7
, 1
, 1
)
, (
4
, 8
, 2
, 1
)
, (
4
, 9
, 1
, 1
)
, (
4
, 10
, 1
, 1
)
, (
4
, 11
, 1
, 1
)
, (
4
, 12
, 1
, 1
)
, (
4
, 13
, 1
, 1
)
, (
4
, 14
, 1
, 1
)
, (
4
, 15
, 1
, 1
)
, (
4
, 16
, 1
, 1
)
, (
4
, 17
, 1
, 1
)
;
-- User Role link
INSERT INTO fetchmetrics.DOG_User_Role_Link (
id_user
, id_role
, id_user_created_by
)
VALUES
(
1
, 1
, 1
)
, (
2
, 3
, 1
)
, (
3
, 2
, 1
)
, (
4
, 2
, 1
)
;
# Unit of Measurement
INSERT INTO fetchmetrics.DOG_Unit_Measurement (
name_singular, name_plural, symbol, is_base_unit, is_unit_of_distance, is_unit_of_mass, is_unit_of_time, is_unit_of_volume
)
VALUES
('metre', 'metres', 'm', 1, 1, 0, 0, 0)
, ('millimetre', 'millimetres', 'mm', 0, 1, 0, 0, 0)
, ('kilogram', 'kilograms', 'kg', 1, 0, 1, 0, 0)
, ('gram', 'grams', 'g', 0, 0, 1, 0, 0)
, ('litre', 'litres', 'L', 0, 0, 0, 0, 1)
, ('millilitre', 'millilitres', 'mL', 0, 0, 0, 0, 1)
, ('item', 'items', 'x', 0, 0, 0, 0, 0)
, ('second', 'seconds', 's', 1, 0, 0, 1, 0)
, ('hour', 'hours', 'h', 0, 0, 0, 1, 0)
, ('day', 'days', 'd', 0, 0, 0, 1, 0)
, ('ratio', 'ratios', '/', 0, 0, 0, 0, 0)
;
# Unit of Measurement Conversion
INSERT INTO fetchmetrics.DOG_Unit_Measurement_Conversion (
id_unit_derived
, id_unit_base
, display_order
, multiplier_unit_base
, increment_unit_base
, apply_multiplier_before_increment
)
VALUES
(
2 -- id_unit_derived
, 1 -- id_unit_base
, 1 -- display_order
, 0.001 -- multiplier_unit_base
, 0 -- increment_unit_base
, apply_multiplier_before_increment
)
, (
4 -- id_unit_derived
, 3 -- id_unit_base
, 1 -- display_order
, 0.001 -- multiplier_unit_base
, 0 -- increment_unit_base
, apply_multiplier_before_increment
)
, (
6 -- id_unit_derived
, 5 -- id_unit_base
, 1 -- display_order
, 0.001 -- multiplier_unit_base
, 0 -- increment_unit_base
, apply_multiplier_before_increment
)
, (
9 -- id_unit_derived
, 8 -- id_unit_base
, 1 -- display_order
, 24 -- multiplier_unit_base
, 0 -- increment_unit_base
, apply_multiplier_before_increment
)
;
-- Project-specific tables
INSERT INTO fetchmetrics.DOG_Dog (
name
, appearance
, mass_kg
)
VALUES
(
'Molly'
, 'Cute'
, 20
)
;
INSERT INTO fetchmetrics.DOG_Breed (
code
, name
)
VALUES
(
'BORDER_COLLIE'
, 'Border Collie'
)
;
INSERT INTO fetchmetrics.DOG_Dog_Breed_Link (
id_dog
, id_breed
, lineage_ratio
)
VALUES
(
1
, 1
, 1
)
;
INSERT INTO fetchmetrics.DOG_Drive (
code
, name
)
VALUES
(
'PREY'
, 'Prey'
)
, (
'PACK'
, 'Pack'
)
;
INSERT INTO fetchmetrics.DOG_Dog_Drive_Link (
id_dog
, id_drive
, dominance_ratio
)
VALUES
(
1
, 1
, 0.5
)
, (
1
, 2
, 0.5
)
;
/*
INSERT INTO fetchmetrics.DOG_Understanding_Level (
code
, name
)
VALUES
(
'UNKNOWN'
, 'Not known'
)
, (
'INTRODUCED'
, 'Has been introduced'
)
, (
'RECOGNISES_COMBINED_VISUAL_AND_VERBAL_SIGNAL'
, 'Combined visual and verbal signal recognised'
)
, (
'RECOGNISES_VISUAL_SIGNAL'
, 'Visual signal alone recognised'
)
, (
'RECOGNISES_VERBAL_SIGNAL'
, 'Verbal signal alone recognised'
)
, (
'UNDERSTOOD'
, 'Understood'
)
;
INSERT INTO fetchmetrics.DOG_Obedience_Level (
code
, name
)
VALUES
(
'REFUSAL'
, 'Refuses to obey'
)
, (
'ON_HER_TERMS'
, 'Might obey if she feels like it'
)
, (
'OBEYS_UNDISTRACTED'
, 'Obeys without distractions'
)
, (
'OBEYS_MILDLY_DISTRACTED'
, 'Obeys when mildly distracted'
)
, (
'OBEYS_PERFECTLY'
, 'Obeys in all situations'
)
;
*/
INSERT INTO fetchmetrics.DOG_Command_Category (
code
, name
)
VALUES
(
'ACTIVITIES'
, 'Activities'
)
, (
'BASIC_OBEDIENCE'
, 'Basic obedience'
)
, (
'BEHAVIOUR_MODIFICATION'
, 'Behaviour modification'
)
, (
'BODY_PARTS'
, 'Body parts'
)
, (
'CLOTHING_AND_EQUIPMENT'
, 'Clothing and equipment'
)
, (
'COMPARISON'
, 'Comparison'
)
, (
'ADJECTIVES'
, 'Compliments and insults (adjectives)'
)
, (
'EMOTIONAL_STATE'
, 'Emotional state'
)
, (
'ENVIRONMENT'
, 'Environment'
)
, (
'ESSENTIAL_NEEDS'
, 'Essential needs'
)
, (
'IMPULSE_CONTROL'
, 'Impulse control'
)
, (
'LOCATION'
, 'Location'
)
, (
'MANNERS'
, 'Manners'
)
, (
'MEALTIME'
, 'Mealtime'
)
, (
'PARTY_TRICK'
, 'Party trick'
)
, (
'PEOPLE'
, 'People'
)
, (
'PLAY'
, 'Play'
)
, (
'POSITION'
, 'Position'
)
, (
'QUESTIONS'
, 'Questions'
)
, (
'SERVICE'
, 'Service'
)
, (
'TIME_AND_SCHEDULING'
, 'Time and scheduling'
)
, (
'UTILITY'
, 'Utility'
)
;
/*
INSERT INTO fetchmetrics.DOG_Command (
code
, name
)
VALUES
(
'lick'
, 'nips'
)
;
*/
/*
INSERT INTO fetchmetrics.DOG_Dog_Command_Link (
id_dog
, id_command
, id_understanding_level
, id_obedience_level
, notes
)
VALUES
(
'lick'
, 'nips'
)
;
*/
INSERT INTO fetchmetrics.DOG_Command_Modality (
code
, name
)
VALUES
(
'VISUAL'
, 'Visual signal'
)
, (
'VERBAL'
, 'Verbal signal'
)
, (
'BUTTON'
, 'Button press'
)
;
INSERT INTO fetchmetrics.DOG_Location (
code
, name
)
VALUES
(
'HOME'
, 'Home'
)
;
/*
INSERT INTO fetchmetrics.DOG_Location_Link (
id_location_parent
, id_location_child
)
VALUES
(
1
, 2
)
;
*/
INSERT INTO fetchmetrics.DOG_Button_Shape (
code
, name
, description
)
VALUES
(
'ROUND'
, 'Round'
, 'Cylindrical'
)
, (
'HEXAGONAL'
, 'Hexagonal'
, 'Hexagonal prism'
)
;
INSERT INTO fetchmetrics.DOG_Colour (
code
, name
)
VALUES
(
'RED'
, 'Red'
)
, (
'GREEN'
, 'Green'
)
;
/*
INSERT INTO fetchmetrics.DOG_Image (
id_file_type
, id_dog
, path
, display_order
)
VALUES
(
1
, 1
, NULL
, NULL
)
;
*/
/*
INSERT INTO fetchmetrics.DOG_Button_Icon (
id_image
, code
, name
, description
)
VALUES
(
1
, NULL
)
;
*/
/*
INSERT INTO fetchmetrics.DOG_Command_Button_Link (
id_command
, id_button_shape
, id_button_colour
, id_button_icon
, id_location
)
VALUES
(
1 -- AS id_command
, 1 -- AS id_button_shape
, 1 -- AS id_button_colour
, NULL -- AS id_button_icon
, 1 -- AS id_location
)
;
*/
INSERT INTO fetchmetrics.DOG_Weather (
code
, name
)
VALUES
(
'CLEAR_SUNNY'
, 'Sunny and clear'
)
, (
'LIGHTLY_CLOUDY_SUNNY'
, 'Sunny with some clouds'
)
, (
'CLOUDY'
, 'Cloudy'
)
, (
'RAINY'
, 'Raining'
)
, (
'SNOWING'
, 'Snowing'
)
, (
'THAWING'
, 'Thawing'
)
;
INSERT INTO fetchmetrics.DOG_Lighting_Level (
code
, name
)
VALUES
(
'BRIGHT'
, 'Bright'
)
, (
'MODERATELY_BRIGHT'
, 'Moderately Bright'
)
, (
'DAWN_DUSK'
, 'Dawn or Dusk'
)
, (
'DARK_WITH_SOME_LIGHTING'
, 'Dark With Some Lighting'
)
, (
'DARK'
, 'Dark'
)
;
/*
INSERT INTO fetchmetrics.DOG_Assessment (
id_weather
, id_lighting_level
, id_location
, id_user_handler
, notes
, difficulty_level
, active
)
VALUES
(
)
;
*/
INSERT INTO fetchmetrics.DOG_Distraction_Type (
code
, name
)
VALUES
(
'RESTLESSNESS'
, 'Restlessness'
)
, (
'LIVE_PREY'
, 'Live Prey'
)
, (
'DEAD_PREY'
, 'Dead Prey'
)
, (
'VEHICLES_MACHINES'
, 'Vehicles and Machines'
)
, (
'EXPLOSION'
, 'Explosion'
)
, (
'Treat'
, 'Treat'
)
, (
'TOY'
, 'Toy'
)
, (
'SQUEAKY_TOY'
, 'Squeaky Toy'
)
;
INSERT INTO fetchmetrics.DOG_Distraction_Intensity_Level (
code
, name
)
VALUES
(
'NEGLIGIBLE'
, 'Negligible'
)
, (
'MILD'
, 'Mild'
)
, (
'MODERATE'
, 'Moderate'
)
, (
'STRONG'
, 'Strong'
)
, (
'EXTREME'
, 'Extreme'
)
;
/*
INSERT INTO fetchmetrics.DOG_Distraction (
id_assessment
, id_distraction_type
, id_intensity_level_emotional
, id_intensity_level_scent
, id_intensity_level_sight
, id_intensity_level_sound
, id_intensity_level_touch
, quantity
, proximity_metres
, active
)
VALUES
(
)
;
*/
INSERT INTO fetchmetrics.DOG_Bribe (
code
, name
)
VALUES
(
'NONE'
, 'None'
)
, (
'TREAT'
, 'Treat'
)
, (
'FAVOURITE_TREAT'
, 'Favourite treat'
)
, (
'TOY'
, 'Toy'
)
, (
'FAVOURITE_TOY'
, 'Favourite Toy'
)
, (
'SQUEAKY_TOY'
, 'Squeaky Toy'
)
;
/*
INSERT INTO fetchmetrics.DOG_Assessment_Command_Modality_Link (
id_assessment
, id_command
, id_command_modality
, id_bribe
, distance_from_handler_metres
, is_in_sight_of_handler
, is_in_scent_range_of_handler
, is_in_hearing_range_of_handler
, is_on_lead
, trial_count
, active
)
VALUES
(
)
;
*/
INSERT INTO fetchmetrics.DOG_Response_Quality_Metric (
id_unit_measurement
, code
, name
, value_min
, value_max
)
VALUES
(
8
, 'RESPONSE_TIME'
, 'Response Time'
, 0
, NULL
)
, (
11
, 'ACCURACY_RATIO'
, 'Accuracy Ratio'
, 0
, 1
)
, (
8
, 'COMPLIANCE_DURATION'
, 'Compliance Duration'
, 0
, NULL
)
, (
11
, 'PRECISION_RATIO'
, 'Precision Ratio'
, 0
, 1
)
;
INSERT INTO fetchmetrics.DOG_Obedience_Level (
code
, name
)
VALUES
(
'EAGER'
, 'Eager'
)
, (
'FIRM_LOOK'
, 'After Firm Look'
)
, (
'POWER_POSE'
, 'After Power Pose'
)
, (
'THREATEN_TO_APPROACH'
, 'After Threatening to Approach'
)
, (
'LITTLE_MOVE'
, 'After Moving a Few Steps'
)
, (
'HALF_APPROACH'
, 'After Moving Half Way'
)
, (
'MOST_APPROACH'
, 'After Approaching Most of The Way'
)
, (
'TOUCH_COLLAR'
, 'After Touching Collar'
)
, (
'RUN_AWAY_AND_RETURN'
, 'After Running Away And Returning'
)
, (
'LEAD'
, 'After Being Lead by Collar or Lead'
)
, (
'CHECK_BRIBE'
, 'After Check or Bribe'
)
, (
'CHECKS_BRIBES'
, 'After Multiple Checks and/or Bribes'
)
, (
'REFUSAL'
, 'None - Refusal'
)
, (
'REFUSAL_RUN_AWAY'
, 'Refused and Ran Away Refusing to Return'
)
;
/*
Post Excel-insert:
SELECT COUNT(*) FROM fetchmetrics.DOG_Command_Temp;
CALL fetchmetrics.p_dog_save_command (
'nipples'
, (SELECT GUID FROM fetchmetrics.DOG_Command_Temp COMMAND_TEMP ORDER BY id_temp DESC LIMIT 1)
, 1
, 1
);
SELECT *
FROM fetchmetrics.DOG_Dog;
/ *
SELECT *
FROM fetchmetrics.DOG_Command;
* /
SELECT *
-- DELETE
FROM fetchmetrics.DOG_Obedience_Level;
/ *
DELETE FROM fetchmetrics.DOG_Dog_Command_Link;
INSERT INTO fetchmetrics.DOG_Dog_Command_Link (
id_dog
, id_command
, id_understanding_level
, id_obedience_level
, notes
)
SELECT
DOG.id_dog
, COMMAND.id_command
,
FROM fetchmetrics.DOG_Dog DOG
CROSS JOIN fetchmetrics.DOG_Command COMMAND
WHERE DOG.name = 'Molly'
* /
SELECT * FROM fetchmetrics.DOG_Dog_Command_Link;
*/