Pregunta

I have created the ERD which is given below. I need to create tables using the below ERD, but I need to normalize first.

This is how it goes if I normalize the practitioner table given in the below erd (as far as I understand):

            practitionerID, DoctorID-> PatientID

            PractitionerID-> patientID

So if I go to normalize this, I will end up having same primary key for both tables. Which is not appropriate in normalizing, so am really confused.

Since the relationship between a practitioner and a patient is many to many, the table will end up having duplicated data. This is the ERD:

enter image description here

How do I normalize this?

¿Fue útil?

Solución

First of All.

What is normalization.

In relational database design, the process of organizing data to minimize redundancy. Normalization usually involves dividing a database into two or more tables and defining relationships between the tables. The major aim of normalization is that reduce the repeated data from the table.

Data redundancy occurs in database systems which have a field that is repeated in two or more tables. For instance, when customer data is duplicated and attached with each product bought then redundancy of data is a known source of inconsistency, since customer might appear with different values for given attribute.

Your Solution

Now you have two main tables that is doctors and patients and definitely they have many to many relationship between each other.

When you make these two tables and keep them in MySQL Workbench or in SQLYog by looking their relationship, they will give three tables as you shown in your question i.e practitioner table extra.

Now it is your solution.

You first make the table doctor.

Second you make the table patient.

Now when you insert information then the info will we inserted into their respective tables. mean patient info into patient table and doctor info into doctor table.

But when you assign different patient to different doctor, then their primary key will be inserted into practitioner table.

So now when you need info about any patient, then you can use practitioner table, how ? from the the patient id get all the list of doctors and same as in doctors.

When you keep more info like Patient history, patient other info, then you need to draw more tables for that.

So from that view, you data do not get repeated and that is normalization.

To make your database more secure and consistent, you should need to add UNIQUE KEY into your doctor and patient table by keeping username or email unique, mean if any one get registered then 2nd time they can't.

Hope it will help you.

If you need to ask more then inform me .

Thanks

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top