Professional Documents
Culture Documents
By:
James Carignan
Smith Gaddy
Sam Herrera
These business rules have been set up to allow us to begin to plan out how we are going to implement our
database for Pine Valley. The following business rules apply for our ER Model:
Guards can post security in one or many cell blocks depending on their
Security level
After speaking with the warden and gathering the data we needed, we then went on to design our ER
model for the prison. The following ER model contains our relationships, cardinalities, and abides by our
Business Rules devised in Phase 2-1.
After designing our ER model for the Pine Valley Correctional Institution we were then tasked with
taking our completed ER model, identifying our relations, and bring each relation into the Third Normal
Form. The following is our completed logical schema design, with each relation in the Third Normal
Form.
After receiving all the information from our ER model, logical schema, and personnel data, we were able
to design our database for Pine Valley. The following describes our data in the database.
Activity Table: Each inmate is allowed to do various activities across the prison. This table lists the
location, name, and time for each activity available. The Primary Key is the Activity_ID, and each other
attribute is Not Null.
Cell Table: Each inmate is assigned to their own cell. Each cell is described by its Cell Number, and the
name of the inmate in the cell. The Primary Key is the Cell Number, and both attributes are Not Null.
Cell Block Table: All cells are apart of various Cell Blocks that contain multiple cells. Each Cell Block is
identified by a Cell Block ID, a Cell Block Letter, and the various Cell Numbers that identify the cells
that are apart of that Cell Block. The Primary Key is the Cell Block ID. The Foreign Key is the Cell
Number taken from the Cell Table. All attributes are Not Null.
Employee Table: All of the employees at the Pine Valley Correctional Institution are listed in the
Employee Table. These employees are identified by an ID_Number, and a Name. Their Job Description
describes what job they hold in Pine Valley. Their CellBlock_ID details which Cell Block they are
assigned to work in. The Primary Keys are the ID_Number and the CellBlock_ID. The Foreign Key is the
CellBlock_ID from the Cell Block Table. All of the attributes are Not Null.
Guards Table: All of the guards that are employed at Pine Valley are shown in this table. Each guard is
identified by an ID_Number. The Security Level describes which Cell Block the guard is allowed to enter
based on the Cell Blocks security level needed for the inmates. Each guard is also identified by a Rank
that shows which guard is in charge. The Primary Key is the ID_Number. The Foreign Key is also the
ID_Number from the Employees Table. All of the attributes are Not Null.
Infirmary Table: Each inmate that is injured or becomes sick, will be sent to the infirmary to recover.
Each infirmary is identified by the Cell Block ID that tells which cell block the infirmary is in. The Blood
Type, Height, and Weight identify more information about the inmate. The Date Admitted and Date
Released track when inmates enter and leave the infirmary. The Primary Key and Foreign Key is the Cell
Block ID. All attributes are Not Null.
Inmate Table: Each inmate in Pine Valley is entered into the Inmate Table. Each inmate is identified by
an ID_Number. Their crime is listed by the Crime attribute. Their Name and Date of Birth are also
identified. The Primary Key is the ID_Number. Each attribute is Not Null.
Nurse Table: Each nurse that works for Pine Valley is listed in the Nurse Table. They are all identified by
their ID_Number. They are also assigned a Security Level that details which inmates they are allowed to
work with. The Primary Key is the ID_Number. All attributes are Not Null.
Pine Valley Correctional Institution Database Queries: The following queries were executed in order
to acquire varying data fields that were needed for the facility.
SQL Query #1: Pine Valley officials inquire which activity begins at 7:50 pm in order to increase the
guard presence at the activity due to recent gang violence.
SELECT activity.name FROM activity WHERE activity.time = '1950';
Output:
SQL Query #2: Pine Valley officials are looking at new ways to organize their Nurses in the infirmaries.
They need an alphabetical list of all nurses currently employed at Pine Valley.
SELECT employees.name AS Nurses FROM employees WHERE job_description =
'Nurse' ORDER BY employees.name;
Output:
SQL Query #3: Pine Valley officials are looking at the effectiveness of their infirmary system
over the years. They need the names of all of the inmates that are still admitted in the
infirmary.
SELECT cell.Inmate_Assigned FROM cell, cellblock, infirmary WHERE
infirmary.Date_Released = 'Pending' AND infirmary.CellBlock_ID =
CellBlock.CellBlock_ID AND cellblock.Cell_Number = cell.Cell_Number
ORDER BY cell.Inmate_Assigned;
Output:
SQL Query #4: Pine Valley officials are trying to gather data on the health of most of the
prison population. They would like to know the names of all inmates that are over the weight
of 165.
SQL Query #5: For administrative purposes, Pine Valley officials are looking for all of the
nurses and guards that are assigned the same security level.
SELECT * FROM mydb.nurse INNER JOIN mydb.guards ON
nurse.security_level = guards.Security_Level;
Output:
Conclusion: All queries returned adequate results for the Pine Valley Correctional Institutions
administration to complete all studies in progress.