Database design and Development

43
Database Design & Development Dec 2010 Fin al ©NCC Education International Advanced Diploma in Computer Studies Database Design & Development

Transcript of Database design and Development

Page 1: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Page 2: Database design and Development

Statement and Confirmation of Own Work

Programme/Qualification name:

Each NCC Education assessed assignment submitted by you must have this statement attached to the assignment as the cover page or it will not be accepted for marking. Please ensure that this statement is either firmly attached to the cover of the assignment or electronically inserted into the front of the assignment.

Student declaration

I have read and understood NCC Education’s Policy on Academic Dishonesty andPlagiarism.

I can confirm the following details:

Student ID/Registration number:

Name:

Centre Name:

Module Name:

Module Leader:

Number of words:

I confirm that this is my own work and that I have not plagiarized any part of it. I have also noted the assessment criteria and pass mark for assignments.

Due Date:

Student Signature:

Page 3: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Submitted Date:

Page 4: Database design and Development

Acknowledgment

I am Md. Mahbub Alam is grateful to Daffodil Institute of IT (DIIT) for giving the chance to do

the assignment in the field of Database design and Development. I am also grateful & like to

thank Md. Ashik Mahmud Lecturer of Database Design & Development of DIIT. His

continues support, interest & encouragement help me to complete this assignment. Huge

unknown things are now know to me by doing this assignment. In class room we collect

knowledge about database but practically I collect knowledge by doing this assignment. It

was a glorious memory by doing this assignment in my Life.

Page 5: Database design and Development

Task - 1

Entity Relationship Diagram (ERD):

DOCTORDoctorIDDoctorNameDoctorAddressDoctorTelephoneDoctorMobileBranchID

ANIMALTYPEAnimalTypeIdAnimalTypeName

BRANCHBranchIDBranchNameBranchAddressBranchTelephoneOpeningHourEmergencyTelephone

SPECIALIZATIONAnimalTypeIdDoctorIDSpecialization1Specialization2Specialization3

BREEDBreedIDAnimalTypeIdBreedName

Need for

Need

Given byGives

NeedFor

Work in a Have

For

Need

Need

Need

Need

For

OWNEROwnerIDOwnerNameOwnerAddressOwnerTelephoneOwnerMobile

ANIMALAnimalIDOwnerIDBreedIDAgeSexAnimalName

APPOINTMENTAppointmentIDAnimalIDDoctorIDAppointmentDateAppointmentTimeChargeAppointmenntTime

Need

Has a

Have a

Need

R1

R2

Made by

Make

Made By

Makes

For

Record ofR3

R4

R5

R6

R7

R8

R9

R11

R12

R10

PRESCRIPTIONPrescriptionIDAppointmentIDPeriod(Day)

PRE-DRUGPrescriptionIDDrugID

DRUGDrugIDDrugNameCostDrugTypeID

DRUGTYPEDrugtypeIDDrugType

Page 6: Database design and Development

Representing Entities:

Owner Entity defined as below:

Entity : Owner

Description : Authoritarian of pets.

Identifying Attribute : OwnerID

Other Attribute : OwnerName, OwnerAddress, OwnerTelephone, OwnerMobile.

Animal Entity defined as below:

Animal Type Entity defined as below:

Entity : Doctor

Description : Consultant of animals.

Identifying Attribute : DoctorID

Other Attribute : DoctorName, DoctorAddress, DoctorTelephone, DoctorMobile, BranchID,

Doctor Entity defined as below:

Branch Entity defined as below:

Entity : Branch

Description : Local office of the Headquarter.

Identifying Attribute : BranchID

Other Attribute : BranchName, BranchAddress, BranchTelephone, OpeningHour, EmergencyTelephone.

Entity : Animal

Description : Pet of owner.

Identifying Attribute : Animal ID

Other Attribute : OwnerID, BreedID, Age, Sex, animalName

Entity : AnimalType

Description : Kinds of Animal.

Identifying Attribute : AnimalTypeID

Other Attribute : AnimalTypeName.

Page 7: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Drug Entity defined as below:

Entity : Drug

Description : Medicine of pets.

Identifying Attribute : DrugID

Other Attribute : DrugName, Cost, DrugType.

Pre- Drug Entity defined as below:

Appointment Entity defined as below:

Entity : Appointment

Description : Proposal for the meeting time.

Identifying Attribute : Appointmen ID

Other Attribute : AnimalID, DoctorID, AppointmentDate, AppointmentTime, Charge, appointmentTime

Prescription Entity defined as below:

Entity : Prescription

Description : Doctor Instruction about Medicine.

Identifying Attribute : PrescriptionID

Other Attribute : AppointmentID, Period(Day

Drug Type defined as below:

Entity : DrugType

Description : Detail about Drug.

Identifying Attribute : DrugTypeID

Other Attribute : Drugtype, Medication, Antibiotic

Breed Entity defined as below:

Entity : Breed

Description : Variety of animal.

Entity : Pre- Drug

Description : Medicine of pets.

Identifying Attribute : DrugID

Other Attribute : PrescriptionID

Page 8: Database design and Development

Identifying Attribute : BreedID

Other Attribute : AnimalTypeID, BreedName

Specialization Entity defined as below:

Entity : Prescription

Description : Doctor Instruction about Medicine.

Identifying Attribute : AnimalTypeID

Other Attribute : DoctorID, Specializaion1, Specializaion2, Specializaion3

Page 9: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Representing Relationship:

Relationship ID : R1Relationship Name : Made by, MakeDescription : Drug type made by drug.Participating Entity : DrugTypeCardinality : OneOptionality : NoneParticipating entity : DrugCardinality : ManyOptionality : None

Relationship ID : R2Relationship Name : Made by, MakeDescription : Prescriptions contain drug information.Participating Entity : DrugCardinality : OneOptionality : NoneParticipating entity : Pre-DrugCardinality : ManyOptionality : None

Relationship ID : R3Relationship Name : For, Record ofDescription : Animal need a prescription to record drugs data.Participating Entity : Pre-DrugCardinality : ManyOptionality : NoneParticipating entity : PrescriptionCardinality : OneOptionality : None

Relationship ID : R4Relationship Name : Need for, NeedDescription : For prescription first have to be make a appointment.Participating Entity : Prescription Cardinality : ManyOptionality : NoneParticipating entity : AppointmentCardinality : OneOptionality : None

Page 10: Database design and Development

Relationship ID : R5Relationship Name : Given by, GivesDescription : To make a meeting with doctor, Animal has to be appointment first.Participating Entity : AppointmentCardinality : OneOptionality : NoneParticipating entity : DoctorCardinality : OneOptionality : None

Relationship ID : R6Relationship Name : For, NeedDescription : Doctor may specialize in the treatment.Participating Entity : DoctorCardinality : One Optionality : NoneParticipating entity : SpecializationCardinality : Many Optionality : None

Relationship ID : R7Relationship Name : Work in, HaveDescription : Doctors are work in a branch.Participating Entity : DoctorCardinality : ManyOptionality : NoneParticipating entity : BranchCardinality : OneOptionality : None

Relationship ID : R8Relationship Name : Need, ForDescription : Specialization needs animalType.Participating Entity : SpecializationCardinality : ManyOptionality : NoneParticipating entity : AnimalTypeCardinality : One Optionality : None

Page 11: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Relationship ID : R9Relationship Name : Need, needDescription : Breed needs AnimalType.Participating Entity : BreedCardinality : ManyOptionality : NoneParticipating entity : AnimalTypeCardinality : OneOptionality : None

Relationship ID : R10Relationship Name : Need, ForDescription : Animal have to make a appointmentParticipating Entity : Animal Cardinality : OneOptionality : NoneParticipating entity : Appointment Cardinality : OneOptionality : None

Relationship ID : R11Relationship Name : Need, NeedDescription : Animal need breed.Participating Entity : Animal Cardinality : Many Optionality : NoneParticipating entity : Breed Cardinality : OneOptionality : None

Relationship ID : R12Relationship Name : Have a, Has aDescription : Owner has an animal.Participating Entity : OwnerCardinality : OneOptionality : NoneParticipating entity : Animal Cardinality : Many Optionality : None

Page 12: Database design and Development

Task – 2

Normalized Entity Tables:

Table Name: Owner

Field Name Data Type Length Null?Primary

KeyForeign

KeyRef

TableOn

DeleteOn

UpdateCheck

OwnerID INTEGER 4Not null

Yes No - - - -

OwnerName VARCHAR 30Not null

No No - - - -

OwnerAddress VARCHAR 50Not null

No No - - - -

OwnerTelephone INTEGER 20Not null

No No - - - -

Owner Mobile INTEGER 20Not null

No No - - - -

Table Name: AnimalField

NameData Type Length Null?

Primary Key

Foreign Key

Ref Table

On Delete On Update Check

AnimalID INTEGER 4Not null

Yes No - - - -

OwnerID INTEGER 4Not null

No Yes Owner CASCADE CASCADE -

BreedID INTEGER 15Not null

No No Breed CASCADE CASCADE -

Age INTEGER 4Not null

No No - - - -

Sex VARCHAR 10Not null

No No - - - -

Table Name: Doctor

Field Name Data TypeLengt

hNull?

Primary Key

Foreign Key

Ref Table

On Delete

On Update

Check

DoctorID INTEGER 4Not null

Yes No - - - -

DoctorName VARCHAR 30Not null

No No - - - -

DoctorAddress VARCHAR 50Not null

No No - - - -

DoctorTelephone INTEGER 20Not null

No No - - - -

DoctorMobile INTEGER 20Not null

No No - - - -

BranchId INTEGER 4Not null

No Yes Branch CASCADE CASCADE -

Page 13: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Table Name: Branch

Field Name Data Type LengthNull

?Primary

KeyForeign

KeyRef

TableOn

DeleteOn

UpdateCheck

BranchID INTEGER 4Not null

Yes No - - - -

BranchName VARCHAR 15Not null

No No - - - -

BranchAddress VARCHAR 50Not null

No No - - - -

BranchTelephone INTEGER 17Not null

No No - - - -

OpeningHour INTEGER 5Not null

No No - - - -

EmergencyTelephone INTEGER 17Not null

No No - - - -

Table Name: Drug

Field Name Data Type LengthNull

?Primary

KeyForeign

KeyRef Table

On Delete

On Update

Check

DrugID INTEGER 4Not null

Yes No - - - -

DrugName VARCHAR 15Not null

No No - - - -

Cost INTEGER 4Not null

No No - - - -

DrugTypeID INTEGER 15Not null

No Yes DrugType CASCADE CASCADE -

Table Name: Pre-Drug

Field NameData Type

LengthNull

?Primary

KeyForeign

KeyRef Table On Delete

On Update

Check

PrescriptionID

INTEGER 4Not null

No Yes Prescription CADCADE CADCADE -

DrugID INTEGER 4Not null

No Yes Drug CADCADE CADCADE -

Table Name: AnimalType

Field Name Data Type Length Null?Primary

KeyForeign

KeyRef

TableOn

DeleteOn

UpdateCheck

AnimalTypeID INTEGER 4Not null

Yes No - - - -

AnimalTypeName VARCHAR 30Not null

No No - - - -

Page 14: Database design and Development

Table Name: Appointment

Field Name Data Type Length Null?Primary

KeyForeign

KeyRef

TableOn

DeleteOn

UpdateCheck

AppointmentID INTEGER 4Not null

Yes No - - - -

AnimalID INTEGER 4Not null

No Yes Animal CASCADE CASCADE -

DoctorID INTEGER 4Not null

No Yes Doctor CASCADE CASCADE -

AppointmentDate VARCHAR 20Not null

No No - - - -

AppointmentTime VARCHAR 10Not null

No No - - - -

Charge INTEGER 4Not null

No No - - - -

Table Name: Prescription

Field NameData Type

LengthNull

?Primary

KeyForeign

KeyRef

TableOn Delete

On Update

Check

AppointmentID INTEGER 4Not null

No No - - - -

AnimalID INTEGER 4Not null

No Yes Animal CASCADE CASCADE -

Period (Day) INTEGER 4Not null

No No - - - -

Table Name: DrugType

Field Name Data Type Length Null?Primary

KeyForeign

KeyRef

TableOn

DeleteOn

UpdateCheck

DrugTypeID INTEGER 5Not null

Yes No - - - -

DrugType VARCHAR 4Not null

No No - - - -

Table Name: Breed

Field Name Data Type LengthNull

?Primary

KeyForeign

KeyRef Table

On Delete

On Update

Check

BreedID INTEGER 5Not null

Yes No - - - -

AnimalTypeID INTEGER 4Not null

No Yes AnimalType CASCADE CASCADE -

BreedName VARCHAR 3Not null

No No - - - -

Page 15: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Table Name: SpecializationField

NameData Type Length Null?

Primary Key

Foreign Key

Ref TableOn

DeleteOn

UpdateCheck

AnimalTypeID

INTEGER 4Not null

No No AnimalType CASCADE CASCADE -

DoctorID INTEGER 4Not null

No Yes Doctor CASCADE CASCADE -

Specialization1

VARCHAR 20Not null

No Yes - - - -

Specialization2

VARCHAR 20Not null

No No - - - -

Specialization3

VARCHAR 20Not null

No No - - - -

Page 16: Database design and Development

Task – 3

Printouts of all tables using Database Management System (DBMS):

Fig: Creating a database of petcare

Page 17: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Fig: Creating a table of animal

Page 18: Database design and Development

Fig: Animal table

Page 19: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Fig: animalType table

Page 20: Database design and Development

Fig: appointment table

Page 21: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Fig: branch table

Page 22: Database design and Development

Fig: breed table

Page 23: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Fig: doctor table

Page 24: Database design and Development

Fig: drug table

Page 25: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Fig: drugType table

Page 26: Database design and Development

Fig: owner table

Page 27: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Fig: prescription table

Page 28: Database design and Development

Fig: prescriptionDrug table

Page 29: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Fig: specialization table

Page 30: Database design and Development

Fig: Table relations are showing here

Page 31: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Task – 4

Printouts of SQL code:

Fig: SQL code of quary1

Page 32: Database design and Development

Output of the Quary1:

Fig: SQL codes output of quary1

Page 33: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

Printouts of SQL code:

Fig: SQL code of Quary2

Page 34: Database design and Development

Output of the Quary2:

Fig: SQL codes output of quary2

Page 35: Database design and Development

Database Design & Development Dec 2010 Final ©NCC Education 2010

International Advanced Diploma in Computer Studies Database Design & Development

TASK-5

Assumptions:

I assume some entities to remove data redundancy on this database. I think this was the best move toward of analyzing, designing and implementing. If I never do that on this database it could be difficult & data can be duplicated. That the reason I made many to many relationship. I think that was a best way to develop this database completely.

Summary :

To developing this database I collect some valuable experience which is helpful & I think that will be help in my practical life when I doing job. This database related to practical life, so I like it very much & when I made it I feel so happy.