662 lines
8.8 KiB
SQL
662 lines
8.8 KiB
SQL
|
|
USE parts;
|
|
|
|
|
|
-- Error Message Types
|
|
/* Existing table */
|
|
INSERT INTO parts.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 parts.CORE_File_Type (
|
|
code
|
|
, name
|
|
, is_image
|
|
)
|
|
VALUES
|
|
(
|
|
'JPG'
|
|
, 'JPG'
|
|
, 1
|
|
)
|
|
;
|
|
|
|
-- Access Levels
|
|
INSERT INTO parts.DOG_Access_Level (
|
|
display_order
|
|
, code
|
|
, name
|
|
, priority
|
|
)
|
|
VALUES
|
|
(
|
|
1
|
|
, 'VIEW'
|
|
, 'View'
|
|
, 3
|
|
)
|
|
, (
|
|
2
|
|
, 'EDIT'
|
|
, 'Edit'
|
|
, 2
|
|
)
|
|
, (
|
|
3
|
|
, 'ADMIN'
|
|
, 'Admin'
|
|
, 1
|
|
)
|
|
;
|
|
|
|
-- Permission Groups
|
|
INSERT INTO parts.DOG_Permission_Group (
|
|
display_order
|
|
, code
|
|
, name
|
|
)
|
|
VALUES
|
|
(
|
|
0
|
|
, 'DOG'
|
|
, 'Dog'
|
|
)
|
|
, (
|
|
1
|
|
, 'USER'
|
|
, 'Admin User'
|
|
)
|
|
;
|
|
|
|
-- Permissions
|
|
INSERT INTO parts.DOG_Permission (
|
|
display_order
|
|
, code
|
|
, name
|
|
, id_permission_group
|
|
, id_access_level_required
|
|
)
|
|
VALUES
|
|
(
|
|
1
|
|
, 'DOG_VIEW'
|
|
, 'View Dog'
|
|
, 1
|
|
, 3
|
|
)
|
|
, (
|
|
1
|
|
, 'DOG_ADMIN'
|
|
, 'Admin Dog'
|
|
, 1
|
|
, 3
|
|
)
|
|
, (
|
|
1
|
|
, 'DOG_CREATE'
|
|
, 'Create Dog'
|
|
, 1
|
|
, 1
|
|
)
|
|
;
|
|
|
|
-- Users
|
|
INSERT INTO parts.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
|
|
)
|
|
;
|
|
|
|
-- Roles
|
|
INSERT INTO parts.DOG_Role (
|
|
display_order
|
|
, code
|
|
, name
|
|
, id_user_created_by
|
|
)
|
|
VALUES
|
|
(
|
|
1
|
|
, 'MANAGER'
|
|
, 'Manager'
|
|
, 1
|
|
)
|
|
, (
|
|
2
|
|
, 'USER'
|
|
, 'User'
|
|
, 1
|
|
)
|
|
;
|
|
|
|
-- Role Permission link
|
|
INSERT INTO parts.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
|
|
)
|
|
, (
|
|
2
|
|
, 1
|
|
, 1
|
|
, 1
|
|
)
|
|
, (
|
|
2
|
|
, 2
|
|
, 1
|
|
, 1
|
|
)
|
|
, (
|
|
2
|
|
, 3
|
|
, 1
|
|
, 1
|
|
)
|
|
;
|
|
|
|
-- User Role link
|
|
INSERT INTO parts.DOG_User_Role_Link (
|
|
id_user
|
|
, id_role
|
|
, id_user_created_by
|
|
)
|
|
VALUES
|
|
(
|
|
1
|
|
, 1
|
|
, 1
|
|
)
|
|
, (
|
|
2
|
|
, 2
|
|
, 1
|
|
)
|
|
, (
|
|
3
|
|
, 2
|
|
, 1
|
|
)
|
|
;
|
|
|
|
-- Project-specific tables
|
|
INSERT INTO parts.DOG_Dog (
|
|
name
|
|
, appearance
|
|
, mass_kg
|
|
)
|
|
VALUES
|
|
(
|
|
'Molly'
|
|
, 'Cute'
|
|
, 20
|
|
)
|
|
;
|
|
|
|
INSERT INTO parts.DOG_Breed (
|
|
code
|
|
, name
|
|
)
|
|
VALUES
|
|
(
|
|
'BORDER_COLLIE'
|
|
, 'Border Collie'
|
|
)
|
|
;
|
|
|
|
INSERT INTO parts.DOG_Dog_Breed_Link (
|
|
id_dog
|
|
, id_breed
|
|
, lineage_ratio
|
|
)
|
|
VALUES
|
|
(
|
|
1
|
|
, 1
|
|
, 1
|
|
)
|
|
;
|
|
|
|
INSERT INTO parts.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 parts.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 parts.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 parts.DOG_Command (
|
|
code
|
|
, name
|
|
)
|
|
VALUES
|
|
(
|
|
'lick'
|
|
, 'nips'
|
|
)
|
|
;
|
|
*/
|
|
|
|
/*
|
|
INSERT INTO parts.DOG_Dog_Command_Link (
|
|
id_dog
|
|
, id_command
|
|
, id_understanding_level
|
|
, id_obedience_level
|
|
, notes
|
|
)
|
|
VALUES
|
|
(
|
|
'lick'
|
|
, 'nips'
|
|
)
|
|
;
|
|
*/
|
|
|
|
INSERT INTO parts.DOG_Location (
|
|
code
|
|
, name
|
|
)
|
|
VALUES
|
|
(
|
|
'LOUNGE'
|
|
, 'Lounge'
|
|
)
|
|
;
|
|
|
|
/*
|
|
INSERT INTO parts.DOG_Location_Link (
|
|
id_location_parent
|
|
, id_location_child
|
|
)
|
|
VALUES
|
|
(
|
|
1
|
|
, 2
|
|
)
|
|
;
|
|
*/
|
|
|
|
INSERT INTO parts.DOG_Colour (
|
|
code
|
|
, name
|
|
)
|
|
VALUES
|
|
(
|
|
'RED'
|
|
, 'Red'
|
|
)
|
|
, (
|
|
'GREEN'
|
|
, 'Green'
|
|
)
|
|
;
|
|
|
|
INSERT INTO parts.DOG_Button_Shape (
|
|
code
|
|
, name
|
|
, description
|
|
)
|
|
VALUES
|
|
(
|
|
'ROUND'
|
|
, 'Round'
|
|
, 'Cylindrical'
|
|
)
|
|
, (
|
|
'HEXAGONAL'
|
|
, 'Hexagonal'
|
|
, 'Hexagonal prism'
|
|
)
|
|
;
|
|
|
|
/*
|
|
INSERT INTO parts.DOG_Image (
|
|
id_file_type
|
|
, id_dog
|
|
, path
|
|
, display_order
|
|
)
|
|
VALUES
|
|
(
|
|
1
|
|
, 1
|
|
, NULL
|
|
, NULL
|
|
)
|
|
;
|
|
*/
|
|
|
|
/*
|
|
INSERT INTO parts.DOG_Button_Icon (
|
|
id_image
|
|
, code
|
|
, name
|
|
, description
|
|
)
|
|
VALUES
|
|
(
|
|
1
|
|
, NULL
|
|
)
|
|
;
|
|
*/
|
|
|
|
/*
|
|
INSERT INTO parts.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 parts.DOG_Drive (
|
|
code
|
|
, name
|
|
)
|
|
VALUES
|
|
(
|
|
'PREY'
|
|
, 'Prey'
|
|
)
|
|
, (
|
|
'PACK'
|
|
, 'Pack'
|
|
)
|
|
;
|
|
|
|
INSERT INTO parts.DOG_Dog_Drive_Link (
|
|
id_dog
|
|
, id_drive
|
|
, dominance_ratio
|
|
)
|
|
VALUES
|
|
(
|
|
1
|
|
, 1
|
|
, 0.5
|
|
)
|
|
, (
|
|
1
|
|
, 2
|
|
, 0.5
|
|
)
|
|
;
|
|
|
|
|
|
|
|
/*
|
|
Post Excel-insert:
|
|
|
|
|
|
SELECT *
|
|
FROM demo.DOG_Dog;
|
|
|
|
/ *
|
|
SELECT *
|
|
FROM demo.DOG_Command;
|
|
* /
|
|
|
|
SELECT *
|
|
-- DELETE
|
|
FROM demo.DOG_Understanding_Level;
|
|
|
|
SELECT *
|
|
-- DELETE
|
|
FROM demo.DOG_Obedience_Level;
|
|
|
|
/ *
|
|
INSERT INTO demo.DOG_Dog_Command_Link (
|
|
id_dog
|
|
, id_command
|
|
, id_understanding_level
|
|
, id_obedience_level
|
|
, notes
|
|
)
|
|
SELECT
|
|
DOG.id_dog
|
|
, COMMAND.id_command
|
|
,
|
|
FROM demo.DOG_Dog DOG
|
|
CROSS JOIN demo.DOG_Command COMMAND
|
|
WHERE DOG.name = 'Molly'
|
|
|
|
* /
|
|
|
|
*/
|