Professional Documents
Culture Documents
Module 4 - Database Schema-SQL Statements
Module 4 - Database Schema-SQL Statements
Sujata Mathew
June 9, 2020
MODULE 4: DATABASE SCHEMA-SQL STATEMENTS 2
FirstName Varchar(50),
MiddleName Varchar(50),
LastName Varchar(50),
Address1 varchar(100),
Address2 varchar(100),
City varchar(100),
State varchar(2),
Zip Integer(5)
);
VALUES('01','Joseph', 'Smith', 'Hillary', ' Melbourne 37th Ave', 'Opp Hilton Hotel', 'Melbourne',
'TZ', '41000');
VALUES('11','Mary', 'Jane', 'Alan', ' New York 37th Ave', 'NY Game Reserve', 'New York',
'NY', '00100')
VALUES('21','Charles', 'Dawkins', 'Murray', 'California 5th Ave', 'Adj Junction Mall', 'Los
VALUES('31','Samuel', 'Harris', 'Festus', 'Maryland 22th Ave', 'Lounge Alfas', 'Baltimore', 'MA',
'00300')
FirstName Varchar(50),
MiddleName Varchar(50),
LastName Varchar(50),
Address1 varchar(100),
Address2 varchar(100),
City varchar(100),
State varchar(2),
MODULE 4: DATABASE SCHEMA-SQL STATEMENTS 4
Zip Integer(5)
);
VALUES('101','Avery', 'Harper', 'Mason', 'Ilinois 7th Ave', 'Platinumz 44', 'Chicago', 'IL',
'10200')
'AL', '37400')
VALUES('121','Arthur', 'Josphat', 'Ephraim', 'Los Palace 13th Ave', 'Jos Delivarna', 'Los
VALUES('131','Smith', 'Jason', 'Bruce', 'Balimore 23th Ave', 'Mary Leaky Water', 'Baltimore',
'MA', '70020')
MODULE 4: DATABASE SCHEMA-SQL STATEMENTS 5
BrandName varchar(150),
GenericName varchar(150),
PackageName varchar(150),
NDC11 varchar(11),
Dosage varchar(11),
Strength varchar(50)
);
Dosage,
Strength)
Dosage,
Strength)
'500mg')
MODULE 4: DATABASE SCHEMA-SQL STATEMENTS 6
Dosage,
Strength)
'100mg')
Dosage,
Strength)
'600mg')
MedicationID integer,
PatientID integer,
PrescriptionDate integer
);
PatientID integer,
DoctorID integer,
ProcedureDate Date,
CPT varchar(150),
ProcedureDescription varchar(150),
AdmissionID integer(8)
);
ProcedureDescription, AdmissionID )
'91827364');
ProcedureDescription, AdmissionID )
VALUES('2020','21', '121', '2019/11/04', 'Chest Wall and Shoulder Girdle Anaesthesia', 'Limb-
ProcedureDescription, AdmissionID )
Examinations', '57939592');
ProcedureDescription, AdmissionID )
'53927473');
MedicationID integer,
PatientID integer,
BillingDate date
);
A “Deleted_Date” Marker-Column
Database users can delete records mistakenly (Liu & Muse, 2017). This challenge affects
database maintenance due to its inability to reverse the action leading to unnecessary loss of data
and declined data integrity. Hence, the “Deleted_Date” column guarantee that the column is not
necessary deleted but rather marked as deleted. In this way, database users enjoy significant
tradeoffs such as having the provision to undo an unintentional deletion of a record (Lacher et
al., 2015). Moreover, the marker-column ensures that a permanent delete action can only be done
from the administrator’s side who can delete the CHECK constraint (Riefstahl, n.d.). With such
Questions
Question 1
Question 2
Question 3
MODULE 4: DATABASE SCHEMA-SQL STATEMENTS 11
Question 4
prescription.MedicationID;
Question 5
SQL Queries
Question 1
Question 2
Question 3
Question 4
Prescription.Date;
Question 5
MaxBrand =
References
Lacher, L., Walia, G., Fagerholm, F., Pagels, M., Nygard, K., & Münch, J. (2015). A behavior
marker tool for measurement of the non-technical skills of software professionals: An empirical
investigation.
Instructors Comments Database Schema-SQL Statements : Sujata, very good create table
statements, but all integer fields, like Patient ID and Medication ID, need a defined length. Your
create statements are also good but integer values are not enclosed in quotes. Very nice addition
of deleted_date.
Instructors Comments SQL Queries: Sujata, your first three queries are perfect in terms of
structure and nearly perfect in syntax. Query four requires the addition of Doctor and please see
the attached for challenging query five. 4. The prescription information along with patient name,
DOB, medication brand name, and prescribing doctor name sorted by most recent date. SELECT
5. The most prescribed generic medication name. SELECT TOP 1 GenericName FROM
MODULE 4: DATABASE SCHEMA-SQL STATEMENTS 14