Vous êtes sur la page 1sur 25

PROCESS IT DATABASE MANAGEMENT SYSTEM (NEWHOPE)

BATCH CODE START DATE END DATE NAME OF THE COODINATOR : B216 : 12/04/10 : 24/05/10 : MRS BOIPELO KENOSI

NAMES OF DEVELOPERS

R093012901261 R093012902023 R093012901259 : R093012901185 R093012901181 R093012901268

: Julius Tjinyeka : Samson Bafana : Julius Phaladi

: Tatlhego Molefe
: Thebe M Lekaukau : Tshiamo Bonyongo

SYSTEM ANALYSIS
New hope is a hospital in which patients are treated and therefore it always maintains patients records. However as a result of the increase in the number of patients, it has become difficult for the staff to maintain the patients records manually. Therefore the management of new hope has decided to come up with a system that will facilitate the recording system of patients records, and it has decided to assign Red Sky Systems to develop a computerized system.

DATABASE DESIGN
Database Name: NEWHOPE Number Of Schemas: 4 Schema Names: 1. 2. 3. 4. Patients Human Resources Facilities Management

Number of Tables: 5 Table Names: 1. Patients.PatientDetails 2. HumanResources.DoctorDetails 3. Faclities.WardDetails 4. Patients.MedicalHistory 5. Management.Payments

SCHEMATIC DIAGRAM OF THE DATABASE[NEWHOPE]

TABLE DESIGN
Database Name: New Hope Patients.PatientDetails Table Field Name PatientID LastName Address Phone_Num Age Height Weight Blood_Grp Admit_Date Discharge_Date DoctorID Ward_Id Data Type int Varchar Varchar Numeric Int Decimal Decimal Char Datetime Datetime Int int Width 30 30 Description Patient number Patient Last Name Patient Address Patient Phone Number Patient Age Patient Height Patient Weight Patient Blood Group Patient Admition Date Patient Discharge Date Doctor number Ward number

PatientID is the primary of the above table. DoctorID, Ward_ID are the foreign keys.

The syntax for creating the table above is as follows. The code was executed successfully.
create table patients.patientdetails (Patient_id int identity CONSTRAINT pk_patientid primary key, Firstname varchar(30)not null, Lastname varchar(30)not null, Address varchar(24)not null, Phone CHAR(20) not null, Age int, Height decimal(5), Weight decimal(4), DOCTORID int CONSTRAINT fk_doctorid foreign key REFERENCES HUMANRESOURCES.DOCTORDETAILS(DOCTORID), WardId int CONSTRAINT fk_wardid foreign key REFERENCES facilities.warddetails(wardid), Admit_date datetime, Discharge_date datetime, Currentdate datetime);

Refer to the screen shoot of this table at the appendix.

HumanResources.DoctorDetails Table Field Name DoctorID First Name Last Name Address Phone_Num Employment_Type Ward_ID Data Type int Char Char Varchar Numeric Char Int Width 30 30 30 30 Description Doctor Number Doctor first Name Doctor Last Name Doctor Address Doctor Phone Number Doctor Employment Type Ward Number

DoctorID is the primary key for the above table and Ward_ID is the foreign key.

The syntax for creating the HumanResources.DoctorDetails is as follows. The table code was executed successfully.
CREATE TABLE HUMANRESOURCES.DOCTORDETAILS (DOCTORID INT IDENTITY CONSTRAINT PK_DOCTORID PRIMARY KEY, FIRSTNAME VARCHAR(30)NOT NULL, LASTNAME VARCHAR(30)NOT NULL, ADDRESS VARCHAR(30)NOT NULL, PHONE_NUM CHAR(30)NOT NULL, EMPLOYMENT_TYPE VARCHAR(30), WARDID INT CONSTRAINT FK_WARDID FOREIGN KEY REFERENCES FACILITIES.WARDDETAILS(WARDID))

Refer to the screen shoot of the above table at the appendix.

Facilities.WardDetails Table Field Name WardID Ward Name Data Type Int char Width 30 Description Ward Number Ward Name

WardID is the primary key in this table. The syntax for creating the above table is as follows. The code was executed successfully.
Create table facilities.warddetails (WardID int identity CONSTRAINT pk_wardid primary key, WardName varchar(30))

The Facilities.WardDetails Table was created successfully.

Patients.MedicalHistory Table Field Name RecordID PatientID DoctorID Disease OriginalWard DischargeWard Data Type Int Int Int Char Char char Width Description Patient RecordID Patient Number Doctor Number Patient Disease Patient Original Ward Patient Discharge Ward

RecordID is the primary key for the above table. PatientID is the foreign key from the Patients.PatientDetails table. DoctorID is also the foreign key from the HumanResources.DoctorDetails table The syntax of creating the above table is as follows. The code was executed successfully.
Create table Patients.MedicalHistory (RecordID int identity CONSTRAINT pk_recordid primary key, Patient_ID int CONSTRAINT FK_patientid FOREIGN KEY REFERENCES Patients.PatientDetails(Patient_ID), DoctorID int CONSTRAINT fk_doctoridW FOREIGN KEY REFERENCES HumanResources.DoctorDetails(Doctorid), Disease varchar(23)not null, OriginalWard int CONSTRAINT fk_originalward FOREIGN KEY REFERENCES FACILITIES.WARDDETAILS(WardID), DischargeWard int CONSTRAINT fk_dischargeward FOREIGN KEY REFERENCES FACILITIES.WARDDETAILS(WardID))

The Patients.MedicalHistory Table was created successfully.

Management.Payments Table Field Name PaymentID PatientID PaymentDate PaymentMethod CC_Num CC_Name Check_Num AdvancePayment FinalPayment PaymentSatus TotalBill CurrentDate Data Type Int Int Datetime Char Numeric char Numeric money money Char Money datetime 200 Width Description Payment Number Patient Number PatientPaymentDate PatientPayment Method Patient Credit Card Number Patient Credit Card Name Patient Check Number Patient AvancePayment Patient FinalPayment Patient PaymentStatus Patient TotalBill Patient CurrentDate

30

PaymentID is the primary key of the above table while PatientID is the foreign key from the Patients.PatientDetails. The syntax for creation of the above table is as follows. The codes were executed successfully.
Create table Management.Payments (PaymentID int identity CONSTRAINT pk_paymentid primary key, Patient_ID int CONSTRAINT FK_patientid FOREIGN KEY REFERENCES Patients.PatientDetails(Patient_ID), PaymentDate datetime, Currentdate datetime, PaymentMethod char(30), CC_Num numeric(12)null, CC_Name varchar(200)null, Check_Num numeric(12)null, AdvancedPayment money not null, FinalPayment money not null, PaymentStatus char(200)not null, TotalBill money not null);

The Management.Payments Table was created successfully.

NEWHOPE DATABASE AND ITS SCHEMAS


The New Hope database was created using the Transact-Sql. The syntax for creating the database is as follows. The code was executed successfully. The create command will create a data file with the name provided and a .mdf file extension, as well as transaction log with an .ldf extension.
CREATE DATABASE NEWHOPE ON (NAME=NEWHOPE_DAT, FILENAME='C:\program files\microsoft SQL server\MSSQL.1\MSSQL\data\NEWHOPE_DATA.MDF', SIZE=10MB, FILEGROWTH=5MB) LOG ON (NAME=NEWHOPE_LOG, FILENAME='C:\program files\microsoft SQL server\MSSQL.1\MSSQL\data\NEWHOPE_LOG.LDF', SIZE=5MB, MAXSIZE=25MB, FILEGROWTH=5MB); GO

Name: Name of the database is specified with a .mdf extension and for log file with .ldf extension. Location: Both the data file and the transaction log file reside in sql servers default data directory. Size: A data file of 10MB was created, and the transaction log file of 5MB was created. File growth in megabytes: When the data file needs to grow, this will add specified 5MB to the file, also the log file will add specified 5MB to the file. Maximum file size: The maximum file size specified for both the data file and transaction log file will prevent the two from filling the entire disc subsystem, which could cause trouble for the operating system. File Name: It specified the path where the transaction log file and data file are saved, e.g. they are stored in the local disc c with different extension. SCHEMAS According to Ron and Ryan (n.d) schema is collection of database objectives associated with one particular database username, and where the pointer is pointing shows the mother table vise versa. The following T-Sql were used to create the New Hope database schemas.

CREATE SCHEMA PATIENTS CREATE SCHEMA HUMANRESOURCES CREATE SCHEMA FACILITIES CREATE SCHEMA MANAGEMENT DROP SCHEMA PATIENTS DROP SCHEMA HUMANRESOSSOURCES DROP SCHEMA FACILITIES DROP SCHEMA MANAGEMENT GO

The schemas were executed successfully. Refer to the appendix. The relationship between the tables in New Hope database was included in the simple create statement of the table . This was done by including the foreign key constraint in the code of each table.

VALIDATION PERFORMED
Patients.PatientDetails VALIDATION REQUIRED PatientID must be unique and auto generated FirstName, LastName and Phone_num should not be left blank Age, Height, Weight, Blood_Grp cannot be less than 0 DoctorID, Ward_ID Phone_Num should be in thefollowing format: [0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9] Admit_Date, Discharge_ Date METHOD(S) USED FOR VALIDATION Primary key Constraint and identity Not null clause in the CREATE TABLE statement Check Constraint Foreign key Constraint Check Constraint

Check Constraint

The syntax or codes for applying the validations of the above table are as follows. The codes were executed successfully.
/*PATIENTS.PATIENTDETAILS*/ /*ALTERED CONSTRAINT */ ALTER TABLE patients.patientdetails ADD CONSTRAINT chk_blood_grp CHECK (BLOOD_GRP IN ('A','B','AB','O')) ALTER TABLE patients.patientdetails ADD CONSTRAINT CHK_PHONE_NUM CHECK (PHONE LIKE '[0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9]') ALTER TABLE patients.patientdetails ADD CONSTRAINT chk_date_variation CHECK (Admit_Date >Currentdate) ALTER TABLE patients.patientdetails ADD CONSTRAINT chk_discharge_date CHECK (DISCHARGE_DATE >CURRENTDATE) ALTER TABLE patients.patientdetails ADD CONSTRAINT chk_current_date variation CHECK ('<ADMIT_DATE','DISCHARGE_DATE') /*USED CONSTRAINT*/ patient_id int identity CONSTRAINT pk_patientid primary key doctorid int CONSTRAINT fk_doctorid foreign key wardid int CONSTRAINT fk_wardid foreign key

The used constraint were included in the simple create statement of table while others were altered of the creation of the table.

HumanResources.DoctorDetails VALIDATION REQUIRED Doctor_ID should be auto generated First Name, Last Name, Address, Phone_Num should not be left blank Employment_Type of a doctor should have the following values: Resident or Visiting Ward_ID Method(s) Used For Validation Primary key Constraint and identification specification Not Null Clause in the CREATE Statement

Foreign key Constraint

The syntax for creating the above table are as follows. The codes were executed successfully.
/*HUMANRESOURCES.DOCTORDETAILS*/ /*ALTERED CONSTRAINT*/ ALTER TABLE HUMANRESOURCES.DOCTORDETAILS ADD CONSTRAINT chk_EMPLOYMENT_TYPE CHECK(EMPLOYMENT_TYPE IN('RESIDENT','VISITING')) ALTER TABLE HumanResources.DoctorDetails ADD CONSTRAINT chk_PHONE_NUM CHECK (PHONE_NUM LIKE '[0-9][0-9]-[0-9][0-9][09]-[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9]') /*USED CONSTRAINT*/ DOCTORID INT IDENTITY CONSTRAINT PK_DOCTORID PRIMARY KEY WARDID INT CONSTRAINT FK_WARDID FOREIGN KEY REFERENCES FACILITIES.WARDDETAILS(WARDID)

The altered constraint were executed successfully after the creation of the table. The used constraint were included in the create table statement.

Facilities.WardDetails VALIDATION REQUIRED Ward_ID should be auto generated Ward Name should have any of the following values: OPD, ICU, CCU, Spl_Ward, General Ward, or Emergency Method(s) Used For Validation Primary key Constraint and Identity Specification Check Constraint

The syntax for creating the above table are as follows. The codes were executed successfully.
/*FACILITIES.WARDDETAILS*/ /*ALTERED CONSTRAINT*/ ALTER TABLE FACILITIES.WARDDETAILS ADD CONSTRAINT chk_WardName CHECK (WardName IN('OPD','ICU','CCU','Spl_Ward','General_Ward', 'Emergency')) /*USED CONSTRAINT*/ WardID int identity CONSTRAINT pk_wardid primary key

Patients.MedicalHistory VALIDATION REQUIRED RecordID should be auto generated PatientID foreign key from the PatientDetails table DoctorID is a foreign key from the DoctorDetails Table OriginalWard is a foreign key from the WardDetails Table DischargeWard is a foreign key from the WardDetails table Method (s) Used For Validation Primary key Constraint AND Identification
PatientID int CONSTRAINT FK_patientid FOREIGN KEY REFERENCES Patients.PatientDetails(Patientid) DoctorID int CONSTRAINT FK_doctorid FOREIGN KEY REFERENCES HumanResources.DoctorDetails(Doctorid) OriginalWard int CONSTRAINT fk_originalward FOREIGN KEY REFERENCES FACILITIES.WARDDETAILS(WardId) DischargeWard int CONSTRAINT fk_dischargeward FOREIGN KEY REFERENCES FACILITIES.WARDDETAILS(WardId)

The syntax for creation of the above table are as follows. The codes were executed successfully.
/*Patients.MedicalHistory*/ /*Used Constraint*/ RecordID int identity CONSTRAINT pk_recordid primary key

PatientID int CONSTRAINT FK_patientid FOREIGN KEY REFERENCES Patients.PatientDetails(Patientid) DoctorID int CONSTRAINT FK_doctorid FOREIGN KEY REFERENCES HumanResources.DoctorDetails(Doctorid) OriginalWard int CONSTRAINT fk_originalward FOREIGN KEY REFERENCES FACILITIES.WARDDETAILS(WardId) DischargeWard int CONSTRAINT fk_dischargeward FOREIGN KEY REFERENCES FACILITIES.WARDDETAILS(WardId)

All the validations or constraint of the Patients.MedicalHistory were included in the create statement of the table. There are no altered constraint in this table. Management.Payments Table VALIDATION REQUIRED PaymentID must be auto generated PatientID is foreign key from the PatientDetails Table Method(s) Used For Validation Identification Specification
Patient_ID int CONSTRAINT FK_patientid FOREIGN KEY REFERENCES Patients.PatientDetails(Patient_ID)

PaymentDate cannot be less than the current Check Constraint date PaymentMethod should have any of the Check Constraint following values: Cash, Check, or Credit_Card CC_Num, CC_Name, Check_Num Null Clause in the CREATE statement AdvancePayment Not Null Clause in the CREATE statement FinalPayment Check Constraint PaymentStatus can have either Paid or Check Constraint Pending. Its value depends on whether the patient has has made the initial payment The syntax for validation of the above table are as follows. The codes were executed successfully.
/*Management.Payments Table*/ /*ALTERED CONSTRAINT*/ ALTER TABLE Management.Payments ADD CONSTRAINT CHK_paymentstatus CHECK(PaymentStatus IN('Paid','Pending')) ALTER TABLE Management.Payments ADD CONSTRAINT CHK_finalpayment CHECK(FINALPAYMENT IN('FinalPayment=Total Bill-AdvancePayment')) ALTER TABLE Management.Payments ADD CONSTRAINT CHK_PaymentDate CHECK(PaymentDate>Currentdate) ALTER TABLE Management.Payments ADD CONSTRAINT chk_paymentmethod CHECK(PaymentMethod IN('Cash','Check','Credit_Card'))

All the constraint of the Management.Payments table were altered using the alter statement.

EXPORTING DATA USING BCP


According to Nielsen P(2007) stated that BCP short for bulk copy program is a command-line variation of bulk operations. It differs from bulk insert in that BCP is command-line executed and can import and export data. Project developers were to use BCP to import details of all doctors who have managed a particular ward, than the details were to stored on the text file. The syntax for performing the above task were typed on the command prompt and executed, unfortunately they executed with errors. Because the BCP is an external program, it need authorization to connect to SQL Server. Refer to the diagram below; Thats the syntax BCP NewHope.HumanResources.DoctorDetails. out c:\DoctorDetails.txt c sNewHope\SQLServer-Usa P123456 Go

BCP was unable to connect to SQL Server Store the payment details for each month in text file The syntax below used to perform the statement. It was executed with errors. BCP NewHope.Management.Payments out c:\Payments.txt c sNewHope\SQLServer02 Usa -P123456

Refer to the diagram below;

BCP was unable to connect to SQLServer.

INDEXES
According to Nielsen P(2007) stated that indexes are the bridge between the query and data. They improve performance by reducing the number of physical page reads required for a table read operation.
/*AN INDEXES TO SPEED UP THE EXTRACTION OF PATIENT DETAILS ADMITTED OR DISCHARGE*/

A nonclustered indexes was created for speeding up the extraction of patient details admitted or discharged. This was done using the syntax below. The codes were executed successfully.
CREATE NONCLUSTERED INDEX idxPatient_ID ON Patients.[PatientDetails] (Patient_ID) INCLUDE (Discharge_Date, Admit_Date);

Refer to the diagram below;

/*AN INDEXES TO SPEED THE EXTRACTION OF PATIENT DETAILS FOR EACH PATIENT WHOSE INITIAL PAYMENT IS PENDING*/

The syntax below was used when creating the indexes for extraction of patient details whose initial payment is pending. The code was executed successfully, see the diagram below;

SECURITY POLICY FOR NEWHOPE


According to Nielsen P(2007) stated that security SQL Server provides set of components, such as principals, securable and permissions, which can be used to apply security at different levels. The syntax below was used to create users/logins for James, Bryan, John and Maria. The codes were executed successfully. See the syntax below;
/********************************USERS/LOGIN********************************* */ /********Creating a login for James as he is the Database Administrator*****/ CREATE LOGIN James WITH PASSWORD = 'Tjinyeka',/******here we are creating a server login****/ DEFAULT_DATABASE = NEWHOPE /*****************below is the code for Brayn as he has dbdeveloper permissions on the server***/ CREATE LOGIN Bryan WITH PASSWORD = 'Thebe',/******here we are creating a server login****/ DEFAULT_DATABASE = NEWHOPE /*******************below is the code for John as he has dbdeveloper permissions on the server**/ CREATE LOGIN John WITH PASSWORD = 'Molf',/******here we are creating a server login****/ DEFAULT_DATABASE = NEWHOPE /********************below is the code for Maria as she has dbdeveloper permissions on the server**/ CREATE LOGIN Maria WITH PASSWORD = 'Bafana',/******here we are creating a server login****/ DEFAULT_DATABASE = NEWHOPE *****************************************************************************

BACKUPING NEWHOPE DATABASE


It is important for organization to backup their database so that in times of system failures they will be able to see/reuse their database. The syntax for backup of New hope database follows. The database was backup and stored in drive C. The codes were executed successfully.
/********Code to backup the newhope database******/ USE master EXEC Sp_Addumpdevice 'Disk','NEWHOPEBackup', 'C:\NEWHOPEbackup.bak'

Refer to the diagram below;

The syntax below is used to backup NewHope to drive c;


/****************************/ BACKUP DATABASE NEWHOPE TO DISK = 'C:\NEWHOPEBackup.bak'

The codes were executed successfully. See the diagram below;

ENCRYPTION
According to Geddes and Grosset(1998) states that encryption is the method of encoding data so that unauthorized users cannot read or otherwise use the data. The Newhope database was encryted and stored in encrypted format. The codes for performing encryption of NewHope database follows; They were executed successfully.
**************************ENCRYPTION***************************************** /*******Creating a Master key*******/ USE NEWHOPE; CREATE MASTER KEY ENCRYPTION BY PASSWORD ='S093012900659' /****************************************************/ USE [NEWHOPE] CREATE CERTIFICATE Payments ENCRYPTION BY PASSWORD = 'S093012900659' WITH SUBJECT = 'Patient Credit Card numbers', /*Here we are creating Certificate to encrypt Credit card numbers*/ START_DATE = '09/12/2009', EXPIRY_DATE = '10/20/2010'; /***********************************************************/ USE [NEWHOPE] CREATE SYMMETRIC KEY Creditkey WITH ALGORITHM = TRIPLE_DES /******************creating A symmentric key*/ ENCRYPTION BY CERTIFICATE Payments; /*******creating a column to store encrypted data*****/ USE [NEWHOPE] ALTER TABLE Management.Payments ADD EncryptedCreditCardNumber varbinary(340); /*********Open the symmentric key with which to encrypt data*************/ USE [NEWHOPE] OPEN SYMMETRIC KEY CreditKey DECRYPTION BY CERTIFICATE Payments WITH PASSWORD = 'S093012900659';

The screen shoot of creating the master key;

ALERT
Creating an alert that triggers James whenever the size of the temporary space in the NewHope database is less than 20MB. The type of alert that triggers James is termed as an SQLServer performance-condition alert. Project developers created this alert using SQLServer management studio. An alert for James was termed as Event Alert Type: SQL Server performance alert Object: SQLServer:Databases Counter: Log Files(s) Size(MB) Instance: NEWHOPE Counter: Falls below Values: 20MB

The above information was provided when creating an SQLServer performance-condition alert that triggers James whenever the size of the temporary space in the NEWHOPE Database is fall below 20MB. The alert was created successfully. See the screen shoot below;

REFERENCE LIST
Asanka,D (2008) sql serve database snapshot, Indian,(Available from; Http//www.sql coffee.com/tips 0004.htm,(Accessed 19 April 2010. Geddes and Grosset., 1998. Dictionary of Computer Terms, Scotland: Childrens Leisure Products Limited. Jorden,L.(2008)., Database snapshot, Mastering SQL serve 2005, India, Wiley Indian Nielsen P., 2007. SQLServer 2005: Bible, India: Wiley India Pvt. Ltd. Robidous,G.(2007) Microsoft SQL serve database development, SQL serve database modeling and design,[online] Available from; Http//www.sql-serve performance.com (Accessed 21 April 2010)

Vous aimerez peut-être aussi