Beruflich Dokumente
Kultur Dokumente
WK3PROJP1HALLA
The SQL commands used to create the entities for Health Firsts database are listed
below. I compiled the SQL into a script and ran it from the command prompt for my database
system. The screenshot after the commands shows the list of tables and column names to verify
that they were created by the script. When using the command prompt in Oracle, you cannot
assign a foreign key to a table before the referenced table has been created; therefore, I used an
ALTER TABLE command to assign the REC_ID from the RECORD table as a foreign key to the
PATIENT table once all others were created. Creating the patient table first without the foreign
key was important due to the high number of references to the PAT_ID as a foreign key. In order
to verify entity and attribute creation, I have added screenshots after the SQL blocks of the
information returned using the command DESCRIBE tablename; (semi-colon is optional).
CREATE TABLE PATIENT (
PAT_ID
VARCHAR2(12) PRIMARY KEY
NOT NULL,
PAT_SOCIAL VARCHAR2(11)
NOT NULL,
PAT_FNAME VARCHAR2(20),
PAT_LNAME VARCHAR2(20),
PAT_INITIAL
VARCHAR2(1),
PAT_ADDRESS
VARCHAR2(100)
NOT NULL,
PAT_DOB
DATE NOT NULL,
PAT_GENDER VARCHAR2(1)
NOT NULL);
Note: this is the final version after the ALTER TABLE command:
WK3PROJP1HALLA
WK3PROJP1HALLA
WK3PROJP1HALLA
WK3PROJP1HALLA
WK3PROJP1HALLA
WK3PROJP1HALLA
CREATE TABLE RECORD (
REC_ID
NUMBER(6) PRIMARY KEY NOT NULL,
PAYER_ID
VARCHAR2(10),
CONSTRAINT REC_PAYER_FK
FOREIGN KEY(PAYER_ID)
REFERENCES PAYER(PAYER_ID),
HIST_REC_ID
NUMBER(6),
CONSTRAINT REC_HIST_FK
FOREIGN KEY(HIST_REC_ID)
REFERENCES HISTORY(HIST_REC_ID),
VITAL_REC_ID
NUMBER(6),
CONSTRAINT REC_VITAL_FK
FOREIGN KEY(VITAL_REC_ID)
REFERENCES VITALS(VITAL_REC_ID),
MEDI_REC_ID
NUMBER(6),
CONSTRAINT REC_MEDI_FK
FOREIGN KEY(MEDI_REC_ID)
REFERENCES MEDICATION(MEDI_REC_ID),
LAB_REC_ID NUMBER(6),
CONSTRAINT REC_LAB_FK
FOREIGN KEY(LAB_REC_ID)
REFERENCES LAB(LAB_REC_ID),
SERV_ID
NUMBER(6),
CONSTRAINT REC_SERV_FK
FOREIGN KEY(SERV_ID)
REFERENCES SERVICES(SERV_ID),
CLAIM_ID
NUMBER(6),
CONSTRAINT REC_CLAIMS_FK
FOREIGN KEY(CLAIM_ID)
REFERENCES CLAIM(CLAIM_ID));