MVC_Hospital

advertisement
Database Management
Professor Chen
Name: __________________
Due Date: _____________
This handout provides you with additional information for the DBMS homework assignment about Mountain View
Community (MVC) Hospital. This is an INDIVIDUAL homework. It means that you are not allowed to communicate
with anyone and the ER-D should be from your own creativity. It helps you to improve your modeling ability.
Figure 1. PATIENT REPORT (a USER VIEW) (Table name: PATIENT)
Patient_
Patient_
Patient_
City, State,
No.
Name
Address
Zip
3249
Baker, Mary
300 Oak St.
Mt. View, CO 80638
09/10/2015
09/18/2015
100A
1837
Thomas, V.M.
137 Pine Crest
Denver, CO 80180
10/01/2015
10/08/2015
100B
6251
Moore, Ann
650 Vadle Ln.
Aspen, CO 83149
10/01/2015
10/07/2015
102B
7325
Kelly, Marie
320 Wall St.
Denver, CO 80183
09/20/2015
09/25/2015
102A
mm/dd/yyyy
mm/dd/yyyy
I5
A15
A20
Date_
Date_
Admitted
A25
Room_
Discharged
No
Note: To make the case simple we assume that there is one visit for every patient
Two ways to INSERT DATE field (1) ’09-OCT-2015’ or (2) TO_DATE (‘09/10/2015’, ‘MM/DD/YYYY’)
Figure 2. ROOM REPORT (a USER VIEW) (Table name: ROOM)
ROOM_NO
ACCOM_ID
DESCRIPTION
PHONE_ EXTENSION
100A
SP
Semi-Private Room
301
100B
SP
Semi-Private Room
303
101A
SP
Semi-Private Room
305
101B
SP
Semi-Private Room
307
102A
PR
Private Room
401
102B
PR
Private Room
403
A4
A2
A20
I3
Data Types:
I: Integer; A: Alphanumeric
mm/dd/yy: DATE , D(8,2): Number with Decimals
(Note that you have to use appropriate data types such as NUMBER or VARCHAR2 from Oracle)
A4
Figure 3. ITEM REPORT (a USER VIEW) (Table name: ITEM)
ITEM_Code
ACCOM_ID
Description
Charge
200
SP
Semi – Private Room
333
TV
Television
5
307
XR
X-Ray Test
40
413
LT
Lab – Test
35
202
PR
Private-Room
300
423
IC
Intensive Care
75
I4
A2
A20
200
D8.2
Note: The above charges are based on number of days or number of times basis.
Figure 4.
PHYSICIAN REPORT (a USER VIEW) (Table name: DOCTOR)
Physician_ID
Phone
Name
4321
608-5583
M.D. Smith
2581
608-5587
M.D. Walter
I4
A8
A15
MVC Hospital Database Application, Page-2
Figure 5. PATIENT CHARGED REPORT (a USER VIEW) (Table name: PATCHRG)
Patient
No.
Patient
Name
Room
Stayed in
3249
Baker, Mary
100A
7325
1837
6251
I5
Kelly, Marie
Thomas, V.M.
Moore, Ann
A30
102A
100B
102B
A4
Treatment
Admin.
Room - SP(8)
TV(1)
X-Ray (5)
Room - PR(5)
X-Ray (7)
Lab-Test (2)
IC(3)
Physician
Cared By
M. D. Smith
M.D. Smith
M.D. Walter
Room - SP(7)
X-Ray (8)
M.D. Walter
Room - PR(6)
TV(1)
X-Ray (9)
Lab-Test (2)
M.D. Walter
M.D. Walter
?????????
A15
Please note that:
1. The number in ( ) represents the total number of times (or days) the patient has been treated during his/her
hospitalization.
2. You should shorten the field’s names with appropriate names whenever they are needed. You might need
more than five tables or create view (with multiple tables) to answer some questions in Phase III.
3. Please note that these five (5) figures are not exactly the same as five tables (entities) that you need to
include in the ER/M. The five figures illustrate the five (5) different reports or user views for this project.
Therefore, the total number of entities you need to create in your ERD/ERM may be different from these five
figures. It means that you may need five or more entities depending on the “art” of your modeling skill.
MVC Hospital Database Application, Page-3
LOGICAL DATABASE DESIGN AND ORACLE IMPLEMENTATION ASSIGNMENTS
Phase I
Logical Design Phase (ER Diagram)
Draw an entity-relationship diagram (enterprise model) for Mountain View Community Hospital, based on this handout.
Your task is to create an ERD/ERM based on the five (5) figures/ reports (i.e. user views) shown above. Read chapters 1
thru 3 thoroughly to finalize your ERD (file name: MVC_PhaseI_ERD_Lastname_Firstname.docx) that should include
the following:
1.
2.
3.
4.
5.
Include entities, associations (with cardinality), attributes, and PK, FK (so that you can do the next step).
Determine and draw the order of entering data (thus you know the order of deletion of data) and
Make sure to include your class and personal information on the first page of the assignment.
Upload ONLY the .docx file (stated above) to the Blackboard (under “Assignments&Cases”) .
Turn in a hardcopy next class.
Please note that these five (5) figures are not exactly the same as five tables (entities) that you need to include in the ER/M
as they only represent the five (5) different reports or user views. Therefore, the total number of entities you need to create
in your ERD/ERM may be different from these five figures. You may need five or more entities depending on the “art” of
your modeling skill.
Assumption: To make the case simple we assume that there is one visit for every patient
1. Include entities, associations (with cardinality), attributes, and pk, fk, composite attributes (__, __, __, …) derived
attribute [ ], multi-value attribute { } and all what you learned so far (so that you can do the next phase).
2. Determine and draw the order of entering data (like you did in the JLDB and NW databases
Phase II. BASIC Implementation using ORACLE – using SQL*PLUS or SQL Developer (DDL and DML for
database creation)
Create a script file (file name: MVC_PhaseII_Lastname_Firstname.sql) that contains a set of commands of DROP,
CREATE and INSERT that performs the same functions as in the script file of JLDB_Build.sql
Save your spooled file (both script file and result from SQL*PLUS) as MVC_PhaseII_Spool_Lastname_Firstname.txt.
Upload both source (*.sql) and the spooled files to Bb.
Phase III. Queries
Create a script file (file name: MVC_PhaseIII_Queries_Lastname_Firstname.sql) containing a set of SQL commands
that answer the following questions (a sample out put is available on the Bb). You may need other SQL commands such as
the one creating database views (from a single table or multiple tables) for the purpose of answering questions easily
(especially for Q#1). You may need to read other references related the SQL from the text book (e.g., Chapters 6 and 7 of
Main text in addition to Oracle text) -- use of appropriate heading and formatting for your output like you did in the past
Oracle assignments; otherwise, major points will be off.
1.
2.
3.
4.
5.
6.
What patient(s) (displayed in patient # order) has/have been charged more than $300 for Item 307?
What physicians have not treated Patient No. 3249? (Hint: SELECT … NOT IN …)
How many procedures have been performed on Patient No.7325? (IC is not included)
How many (distinct) physicians have treated Patient No. 7325?
What physicians have treated Patient No. 7325?
What is the total charged of the Item 307 and 413 to each patient who has had both items billed to their accounts? (use
‘OR’ or IN)
7. What is the total charge for each patient?
Test query one at a time until all queries produce the right outputs (compare yours with the answers posted on the Bb) then
COPY and PASTE them to the SQL> Spool SQL commands (from Phase III 1-7) with their results and save them in the
file of MVC_PhaseIII_Spool_Lastname_Firstname.txt. Finally, you create a WORD file combining all work done from
these three phases (file name: MVC_Hospital_Complete_Lastname_Firstname.docx). The file should contain your class
and personal information, ERM, SQL commands for Phase II and III and the solution of Phase III. Furthermore, query
number and title of each query in Phase III should be retyped and inserted in an appropriate place. Upload all three files
(source (*.sql), spooled and Word files) to Bb.
MVC Hospital Database Application, Page-4
Download