
<p> IST 331. Project – Part 3 Fall 2000 V. Matos</p><p>Physical Database Modeling (PDM)</p><p>In this phase of the project you will create a Physical Database Model for the Mountain View Community Hospital. A PDM Diagram is attached. The diagram shows the tables, their attributes, keys, and the inter-table relationships derived from the Primary/Foreign key connections.</p><p>For each table you should create a script similar to the one below. The script contains the code to generates and populate a table in a SQL environment (particularly in Oracle). Your DBMS should be MS-Access. Certain datatypes must be corrected, such as TEXT instead of VARCHAR2.</p><p>Due date: Th. Oct 26. (Give your instructor a listing of your scripts.)</p><p>/*------* MakeWORK.SQL Victor Matos. 21-oct-94 * This command file implements the following actions: * 1 - creates the WORKSON table using ORACLE DBMS * 2 - populates the WORKSON table inserting several records * 3 - shows the status of the table after insertions are performed *------*/ drop table WORKS_ON; create table WORKS_ON ( MS-Access essn varchar2(9), uses the Text pno number, data type hours number(5,1) ); insert into WORKS_ON values ( 123456789, 1, 32.5 ); insert into WORKS_ON values ( 123456789, 2, 7.5 ); Running the Scripts in MS Access</p><p>Put the following code in an Access Module. </p><p>Public Sub makeTemp() 'The example shows the execution of SQL action queries 'this subroutine could be called from the form: myMakeTables</p><p>Dim myDB As DAO.Database Dim mySQL As String On Error Resume Next 'ignore errors</p><p>'connect to the current MS-Access database Set myDB = CurrentDb()</p><p>'assemble and execute SQL statements 'erase previous versions of the TEMP table mySQL = "drop table TEMP" myDB.Execute mySQL</p><p>'create a new image of the TEMP table mySQL = "create table TEMP (theKey number, theDescription text)" myDB.Execute mySQL</p><p>'populate the TEMP table mySQL = "insert into TEMP values (123, 'ABC')" myDB.Execute mySQL End Sub</p><p>Public Sub makeTempVersion2() 'An example to show the execution of SQL action queries 'this subroutine reads a script file containing the SQL 'code required to create and populate the TEMP table. Dim myDB As DAO.Database Dim mySQLLine As String 'On Error Resume Next 'ignore errors</p><p>'connect to the current MS-Access database Set myDB = CurrentDb()</p><p>'open the disk file – assume each command fits in one line '(each complete SQL line ends with a semicolon) Open "c:\Temp\mySQLScript.txt" For Input As #1 ' Open file. Do While Not EOF(1) ' Loop until end of file. Line Input #1, mySQLLine ' Read line into variable. MsgBox mySQLLine myDB.Execute mySQLLine Loop Close #1 ' Close file.</p><p>End Sub</p><p>Private Sub cmdVersion2_Click() 'invoke routine which reads the script file 'containing the SQL statements Call makeTempVersion2 MsgBox "Done (version2) !!!" End Sub</p><p>The file looks like: drop table TEMP; create table TEMP (theKey number, theDescription text); insert into TEMP values (456, 'XYZ'); NEW. FOR ACCESS 2000 USERS !!!</p><p>The preferred way of programming VBA in Access2000 is based on the ADODB control –rather than DAO. Chapter 12 of the reference book (Mastering Microsoft 2000 Development by Alison Balter) explains how to program the ADODB hierarchy.</p><p>A fragment follows to illustrate the way of programmatically manage the database resources using the Connection, and the Recordset objects of the ADODB control.</p><p>Example1. Executing an Action Query. Sub MakeTable1( ) Dim mySQL as String Dim myConn as ADODB.Connection Set myConn = New ADODB.Connection MyConn.open CurrentProject.Connection mySQL = “create table JUNK(theID as number, theName as Text)” MyConn .Execute mySQL MyConn.Close End Sub</p><p>Example2. Creating a recordset using a connection string Sub CreateRS2( ) Dim myRS as ADODB.Recordset Dim mySQL as String Set myRS = New ADODB.Recordset MySQL = “Select * from Employee where sex = ‘F’ “ MyRS.open mySQL, CurrentProject.Connection While not myRS.EOF Debug.Print myRS(“Lname”) & “ “ & myRS(“Fname”) MyRS.MoveNext Wend MyRS.Close Set myRS = Nothing End Sub Chapter 6 Logical Database Design and the Relational Model</p><p>Relational schemas for Mountain View Community Hospital. WARD</p><p>Ward_No Ward_Name Employee_No</p><p>ASSIGNED</p><p>Ward_No Employee_No Hours</p><p>EMPLOYEE Employee_No Employee_Name</p><p>BED Bed_No Ward_No Room_No Patient_No</p><p>PATIENT</p><p>Patient_No Patient_Name Physician_ID</p><p>PERFORMS</p><p>Patient_No Physician_ID Treatment_No Results</p><p>PHYSICIAN TREATMENT Physician_ID Physician_Name Treatment_No Treatment_Name</p><p>CONSUMES</p><p>Patient_No Item_No Date Quantity</p><p>ITEM Item_No Description Unit_Cost a. Schema for EER diagram (Exercise 1, Chapter4): PERSON</p><p>Person_ID Name Address Birth_Date City_State_Zip Phone</p><p>PATIENT</p><p>PA_Person_ID Contact_Date PH_Person_ID</p><p>PHYSICIAN PH_Person_ID Pager_No Specialty</p><p>VOLUNTEER</p><p>V_Person_ID Skill</p><p>EMPLOYEE</p><p>E_Person_ID Date_Hired</p><p>NURSE</p><p>N_Person_ID Certificate Name</p><p>STAFF</p><p>S_Person_ID Job_Class</p><p>TECHNICIAN</p><p>T_Person_ID Skill</p><p>LAB ASSIGN</p><p>T_Person_ID Name</p><p>LABORATORY CARE CENTER Name Location Name Location To PATIENT RESIDENT</p><p>R_Person_ID Date_Admitted</p><p>OUTPATIENT</p><p>O_Person_ID (Other)</p><p>BED</p><p>Bed_No Room_No R_Person_ID</p><p>VISIT</p><p>O_Person_ID Date Comments</p><p>Following are some sample CREATE TABLE commands.</p><p>CREATE TABLE PATIENT (PATIENT_NO INTEGER Not Null, PATIENT_NAME VARCHAR(25) Not Null, PHYSICIAN_ID VARCHAR(10) Not Null, PRIMARY KEY (PATIENT_NO), FOREIGN KEY (PHYSICIAN_ID) REFERENCES PHYSICIAN (PHYSICIAN_ID));</p><p>CREATE TABLE PHYSICIAN (PHYSICIAN_ID INTEGER Not Null, PHYSICIAN_NAME VARCHAR(25) Not Null, PRIMARY KEY (PHYSICIAN_ID));</p>
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages6 Page
-
File Size-