Você está na página 1de 11

Pine Valley Correctional Institution:

Database Design Final Project


For
CSCI 320 Database Design

By:
James Carignan
Smith Gaddy
Sam Herrera

Phase 1: Description of the Database


We have been tasked with making and maintaining a database system for the Pine Valley
Correctional Institution. The database will record an Inmates date and time of when he was processed
into the prison. The prison will have the Inmates name, date of birth, blood type, and crime (which will
determine which Cell Block the inmate is housed in) and each Inmate will have a specific ID number
(identifier). Height and weight will also be recorded. After the inmate has been processed, they will be
assigned a Cell Block based on the inmates crime. Each Cell Block will have an ID Letter (identifier)
that goes from A through E, which will describe the Inmates security level. Each cell in a Cell Block will
have a cell number and the higher the number, the higher the Cell Block ID Letter.
The guards will have a specific ID number (identifier), name, and security level letter that
describes which cell blocks the guard is authorized to enter. There will also be one guard who is in charge
of all the other guards and is guaranteed full access to all of the Cell Blocks. Along with the guards, the
prison will also have regular employees that help deal with the administrative paper work for each
prisoner. Each employee has their own ID Card Number (identifier) that allows them to move through a
checkpoint within the prison. They are described by a name, job description, and Cell Block. Lastly, the
prison also records all the activities an inmate can participate in. The activities information will include a
specific activity code (identifier), name, time, and place in which it is held.
As far as relationships between each entity, an inmate can only be admitted to one prison while a
prison can hold many inmates. An inmate is housed in one specific cell block depending on his crime and
cell blocks can hold multiple inmates. Guards can post security in one or many cell blocks depending on
their security clearance and cell blocks can hold many guards. There is a guard in charge of all other
guards but all guards report one. Employees may also work in one or many cell blocks and cell blocks can
hold many employees.

Phase 2-1: Business Rules for all Relationships

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:

An inmate can only be admitted to one prison

Pine Valley can hold many inmates

An inmate is housed in one specific Cell Block

Cell Blocks can hold multiple inmates

Guards can post security in one or many cell blocks depending on their
Security level

Cell Blocks can also hold many Guards

There is a Warden in charge of all other guards

Employees may work in many Cell Blocks

Cell Blocks can hold many Employees

Nurses can work in many Cell Blocks

There is only one Infirmary per Cell Block

Infirmaries can hold many nurses

Phase 2-2: ER Model with Relationships

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.

Phase 3: Logical Schema Design

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.

Phase 4: Implementation of the Database

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.

SELECT cell.Inmate_Assigned FROM infirmary, cell, cellblock WHERE


infirmary.weight > '165' AND infirmary.cellblock_id =
cellblock.cellblock_id AND cellblock.cell_number = cell.Cell_Number;
Output:

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.

This Concludes our Project

Você também pode gostar