Jump to content

Table question


jeff5656

Recommended Posts

Lets say I have a database with patient name, diagnosis and date of diagnosis.  Lets say the diagnosis can change every day.  This means that for that ONE patient record, there can be 20 or 30 or more different dates and diagnoses, but all associated with the same patient.  How do I set up the tables? Thanks. I'm trying to understand working with multiple tables but can't seem to get past this yet...

Link to comment
https://forums.phpfreaks.com/topic/136371-table-question/
Share on other sites

Without looking at the normalization you would just need to keep your patients in one table, and your diagnoses in the other, and you join the two on a field called patient_id.  This field would be an auto-incremented number in the patient table.

 

That would be a start anyway.

Link to comment
https://forums.phpfreaks.com/topic/136371-table-question/#findComment-711460
Share on other sites

I may have dyslexia because I can't udnerstand something now.  What if the patient has more than one diagnosis on a given date?  How can you store more than one diagnosis.  If I had a THIRD table with a list of all the diagnoses, how would I store the 3 diagnoses that the patient has on that date?

Link to comment
https://forums.phpfreaks.com/topic/136371-table-question/#findComment-711762
Share on other sites

You only need 2 tables. That is the reason you have the diagnoses table so you can have multiple entries for one user. The date field is no unique and nor should it be. The only part about the diagnose table that should be unique is the diagnoseid. This will prevent errors from coming up with multiple dates for 1 user or the same dates entered twice for one user.

 

That is how it should function, 2 tables are all you need. Stop confusing yourself with thinking about a third table.

Link to comment
https://forums.phpfreaks.com/topic/136371-table-question/#findComment-711768
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.