SQL script for Australia Zoo Wildlife Hospital database creation and data insertion
Verified
Added on  2023/06/11
|14
|3786
|478
AI Summary
This SQL script contains the code for creating tables and inserting data into the Australia Zoo Wildlife Hospital database. The tables include BREAD_TYPE, AFFICITION, ANIMAL_INFO, PATIENT_INFO, PATIENT_DNA, RESCUER_INFO, CONTACTS, CARER_GROUP, CARER_INFO, TREATMENT, and ACCESSION.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
PHONE VARCHAR(20) NOT NULL, STREET VARCHAR(20) NOT NULL, ADDRESS VARCHAR(200) NOT NULL, SUBURB VARCHAR(20) NOT NULL, STATE VARCHAR(10) NOT NULL, COUNTRY VARCHAR(20) NOT NULL, POSTCODE INT(10) NOT NULL, PRIMARY KEY (S_NO) ) ; /*-----------------CARER GROUP TABLES------------------------*/ CREATE TABLE CARER_GROUP ( PERMIT_NUMBER INT NOT NULL, CARERGROUP_NAME VARCHAR(100), PERMIT_VALID VARCHAR(20), PRIMARY KEY (PERMIT_NUMBER) ) ; /*-------------------CARER_INFO TABLES------------------------*/ CREATE TABLE CARER_INFO ( CARER_ID VARCHAR(10) NOT NULL,
PERMIT_NUMBER INT NOT NULL, CARRER_NAME VARCHAR(50) NOT NULL, RELEASE_ANIMAL VARCHAR(50), REG_WILDLIFECARER VARCHAR(100), BECOME_WILDLIDECARER VARCHAR(100), SPECIES VARCHAR(100), SEX VARCHAR(10), WEIGHT VARCHAR(10), AGE VARCHAR(10), SEND_TO_CARER VARCHAR(10), DATE DATE, CARER VARCHAR(10), TRIAGE_NOTES VARCHAR(255), TRIAGE_NURSES VARCHAR(100), PRIMARY KEY (CARER_ID), FOREIGN KEY (PERMIT_NUMBER) REFERENCES CARER_GROUP(PERMIT_NUMBER) ) ; /*------------------TREATMENT TABLES------------------------*/ CREATE TABLE TREATMENT ( TREATMENT_NO INT NOT NULL,
PATIENT_ID VARCHAR(10) NOT NULL, DIAGNOSIS_TYPE VARCHAR(100), DIAGNOSIS_NAME VARCHAR(100), NOTES VARCHAR(255), ACTION_TAKEN VARCHAR(100), START_DATE DATE, STOP_DATE DATE, PRESCRIBED_DATE DATE, PRIMARY KEY (TREATMENT_NO), FOREIGN KEY (PATIENT_ID) REFERENCES PATIENT_INFO(PATIENT_ID) ) ; /*----------------------ACCESSION TABLES------------------------*/ CREATE TABLE ACCESSION ( ACCESSION_NO INT NOT NULL, PATIENT_ID VARCHAR(10) NOT NULL, RESCUER_ID VARCHAR(10) NOT NULL, CARER_ID VARCHAR(10) NOT NULL, S_NO INT NOT NULL, PRIMARY KEY (ACCESSION_NO), FOREIGN KEY (PATIENT_ID) REFERENCES PATIENT_INFO(PATIENT_ID), FOREIGN KEY(RESCUER_ID) REFERENCES RESCUER_INFO(RESCUER_ID), FOREIGN KEY (CARER_ID) REFERENCES CARER_INFO(CARER_ID),
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
FOREIGN KEY (S_NO) REFERENCES CONTACTS(S_NO) ) ; /*------------------UPDATE_CONTACT TABLES------------------------*/ CREATE TABLE UPDATE_CONTACT ( LIST_NO INT NOT NULL, DATE DATE NOT NULL, ACCESSION_NO INT NOT NULL, VET VARCHAR(100), UPDATE_OUTCOME VARCHAR(100), UNDER_VET_CARER VARCHAR(20), WITH_CARER VARCHAR(20), RELEASED VARCHAR(20), OTHER VARCHAR(100), PRIMARY KEY (LIST_NO, DATE), FOREIGN KEY (ACCESSION_NO) REFERENCES ACCESSION(ACCESSION_NO) ) ; /*-------------------------------------------------------INSERT DATA INTO TABLES-----------------------------------------------*/
INSERT INTO RESCUER_INFO VALUES ('12902','WANI', 'BINA', '22a Mary St', '6757566788', '5767767888', 'WANI@GMAIL.COM', '2017-06-05'); /*-----------------------------CONTACTS TABLES------------------------*/ INSERT INTO CONTACTS VALUES (1, 'PERSON', 'YANI', 'LINA', 'SOCIAL', 'YANI@GMAIL.COM','7898678979','67YHU','US','US','US','US',4567); INSERT INTO CONTACTS VALUES (2, 'PERSON', 'VANI', 'LINA', 'SOCIAL', 'VANI@GMAIL.COM','6767787899','68UYU','US','US','US','US',8978); INSERT INTO CONTACTS VALUES (3, 'PERSON', 'CANI', 'LINA', 'SOCIAL', 'CANI@GMAIL.COM','4565787899','56TGU','US','US','US','US',7654); INSERT INTO CONTACTS VALUES (4, 'PERSON', 'NINA', 'LINA', 'SOCIAL', 'NINA@GMAIL.COM','5656676776','6JHHU','US','US','US','US',6789); INSERT INTO CONTACTS VALUES (5, 'PERSON', 'YANI', 'LINA', 'SOCIAL', 'YANI1@GMAIL.COM','5656656777','89UHU','US','US','US','US',0978); /*-----------------------------CARER_GROUP TABLES------------------------*/ INSERT INTO CARER_GROUP VALUES (101, 'CR','VALID'); INSERT INTO CARER_GROUP VALUES (102, 'CR','VALID'); INSERT INTO CARER_GROUP VALUES (103, 'CR','VALID'); INSERT INTO CARER_GROUP VALUES (104, 'CR','VALID'); INSERT INTO CARER_GROUP VALUES (105, 'CR','VALID'); /*---------------------------- CARER_INFO TABLES------------------------*/ INSERT INTO CARER_INFO VALUES ('C101',101,'Jesse','YES', 'YES','YES','TAKECARE ANIMAL','M','45','23','YES','2018-06-1','YES','UIH','IHJK'); INSERT INTO CARER_INFO VALUES ('C102',102,'Annabelle','NO', 'YES','YES','TAKECARE ANIMAL','F','45','24','YES','2018-06-2','YES','MKI','HJNBI'); INSERT INTO CARER_INFO VALUES ('C103',103,'Katherine','YES', 'YES','YES','TAKECARE ANIMAL','M','45','25','YES','2017-06-1','YES','BHI','IHJI');
INSERT INTO CARER_INFO VALUES ('C104',104,'John','NO', 'YES','YES','TAKECARE ANIMAL','F','45','26','YES','2017-06-1','YES','NJI','IJJK'); INSERT INTO CARER_INFO VALUES ('C105',105,'MNI','YES', 'YES','YES','TAKECARE ANIMAL','M','45','27','YES','2018-06-1','YES','BHI','IQJK'); /*-------------------------------TREATMENT TABLES-----------------------------------------------*/ INSERT INTO TREATMENT VALUES (1, 'P101','XYZ','NMU','DMTUFJ','UI','2017-10-10','2018-01-01','2017- 12-01'); INSERT INTO TREATMENT VALUES (2, 'P102','NJH','NJK','KGFZDFCGVH','UQ','2017-10-11','2018-01- 02','2017-12-02'); INSERT INTO TREATMENT VALUES (3, 'P103','BNJ','MN','SDFGHJ','UW','2017-10-12','2018-01-03','2017- 12-03'); INSERT INTO TREATMENT VALUES (4, 'P104','VGH','VB','KJHGFGJ','UE','2017-10-13','2018-01-04','2017- 12-04'); INSERT INTO TREATMENT VALUES (5, 'P105','NBV','CVBN','DFGHJHGJ','UR','2017-10-14','2018-01- 05','2017-12-05'); /*--------------------------ACCESSION TABLES------------------------*/ INSERT INTO ACCESSION VALUES (111,'P101','6033','C101',1); INSERT INTO ACCESSION VALUES (112,'P102','5167','C102',2); INSERT INTO ACCESSION VALUES (113,'P103','12901','C103',3); INSERT INTO ACCESSION VALUES (114,'P104','9217','C104',4); INSERT INTO ACCESSION VALUES (115,'P105','12902','C105',5); /*-----------------------UPDATE_CONTACT TABLES------------------------*/ INSERT INTO UPDATE_CONTACT VALUES (1, '2018-03-01',111,'IJ','GOOD','YES','YES','YES','UHJ');
INSERT INTO UPDATE_CONTACT VALUES (2, '2018-03-02',112,'IJ','GOOD','YES','YES','NO','IJK'); INSERT INTO UPDATE_CONTACT VALUES (3, '2018-03-03',113,'IJ','GOOD','YES','YES','YES','NMK'); INSERT INTO UPDATE_CONTACT VALUES (4, '2018-03-04',114,'IJ','GOOD','YES','YES','NO','UHI'); INSERT INTO UPDATE_CONTACT VALUES (5, '2018-03-05',115,'IJ','GOOD','YES','YES','YES','NBV'); /*-------------------------QUERIES---------------------------------------------------------------------------*/ /*---------------# query 1--------------------------*/ SELECT PATIENT_INFO.PATIENT_ID, ACCESSION.ACCESSION_NO, ANIMAL_INFO.ANIMAL_NAME, BREAD_TYPE.BREAD_NAME , ANIMAL_INFO.ANIMAL_TYPE, TREATMENT.TREATMENT_NO, CARER_INFO.RELEASE_ANIMAL, CARER_INFO.SEND_TO_CARER FROM ANIMAL_INFO, PATIENT_INFO, TREATMENT, ACCESSION, BREAD_TYPE, CARER_INFO WHERE PATIENT_INFO.BREAD_ID=BREAD_TYPE.BREAD_ID AND PATIENT_INFO.ANIMAL_ID=ANIMAL_INFO.ANIMAL_ID AND PATIENT_INFO.PATIENT_ID=ACCESSION.PATIENT_ID AND PATIENT_INFO.PATIENT_ID=TREATMENT.PATIENT_ID AND CARER_INFO.CARER_ID=ACCESSION.CARER_ID AND CARER_INFO.RELEASE_ANIMAL='NO' ORDER BY ANIMAL_INFO.ANIMAL_TYPE; /*---------------# query 2.a.i---------------------*/ SELECT ACCESSION.ACCESSION_NO, ANIMAL_INFO.LOCATION_GOV_AREA_SHIRE, CARER_INFO.DATE FROM ACCESSION, CARER_INFO, ANIMAL_INFO, PATIENT_INFO WHERE ANIMAL_INFO.ANIMAL_ID=PATIENT_INFO.ANIMAL_ID AND PATIENT_INFO.PATIENT_ID=ACCESSION.PATIENT_ID AND CARER_INFO.CARER_ID=ACCESSION.CARER_ID
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
AND CARER_INFO.DATE BETWEEN '2018-06-01' AND '2018-07-01' AND ANIMAL_INFO.LOCATION_GOV_AREA_SHIRE='LOCATION GOV AREA' GROUP BY ANIMAL_INFO.LOCATION_GOV_AREA_SHIRE; /*--------------# query 2.a.ii----------------------*/ SELECT ACCESSION.ACCESSION_NO, AFFICITION.AFFICITION_NAME AS 'CAUSE OF AFFICITION', CARER_INFO.DATE FROM ACCESSION, CARER_INFO, ANIMAL_INFO, PATIENT_INFO, AFFICITION WHERE ANIMAL_INFO.ANIMAL_ID=PATIENT_INFO.ANIMAL_ID AND PATIENT_INFO.PATIENT_ID=ACCESSION.PATIENT_ID AND CARER_INFO.CARER_ID=ACCESSION.CARER_ID AND ANIMAL_INFO.AFFICITION_NO=AFFICITION.AFFICITION_NO AND CARER_INFO.DATE BETWEEN '2018-06-01' AND '2018-07-01' GROUP BY AFFICITION.AFFICITION_NAME; /*----------------# query 2.b ---------------------*/ SELECT COUNT(ACCESSION.ACCESSION_NO) AS 'total number of accession' FROM ACCESSION, CARER_INFO, RESCUER_INFO WHERE ACCESSION.CARER_ID=CARER_INFO.CARER_ID AND ACCESSION.RESCUER_ID=RESCUER_INFO.RESCUER_ID AND CARER_INFO.DATE BETWEEN '2017-06-00' AND '2017-07-00'; /*-----------------# query 3------------------------*/ SELECT CARER, date AS 'expired permit' FROM CARER_INFO GROUP BY CARER HAVING DATE <SYSDATE();