Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

MYSQL

Name: Anonymous 2013-02-25 14:48

Ok so I'm completely new at working with MYSQL/php and I'm trying to create a mock website for a little side project. I'm finding the interaction between PHP and MYSQL pretty easy and I enjoy doing it. The only problem is that I don't think I am following all of the rules when making these databases.

The problem I just realized after creating my database is that I have no foreign keys. I will use this simplified example:

PATIENTS
PATIENT_ID PRIMARY KEY
NAME
ADDRESS
ETC...

To view their medical allergies though I need a separate table so I created:

MEDICAL_ALLERGIES
PATIENT_ID
ALLERGY

Is this bad practice? Essentially I am using the PATIENT_ID as a primary key and foreign key. If I follow this design for my system will it be broken? I just wanted to check before I get any farther.

Name: Anonymous 2013-02-25 14:59

PHP
Yes, it's bad practice.

Name: Anonymous 2013-02-25 15:01

medical_allergies.patient_id is the fk pointing to patients.patient_id and there is little use in a fk pointing to a non-pk. They are different columns as they are in different tables. Everything will be just fine.

Name: Anonymous 2013-02-25 15:21

Thank you, that's all that I was wondering.

Name: Anonymous 2013-02-25 16:36

MySQL still doesn't enforce foreign keys. Everything won't be fine.
Enjoy your jail term for HIPAA violations.

Name: Anonymous 2013-02-26 4:11

>>5
Not >>1, but he did say:
create a mock website
not the actual thing. However, how are you sure he is in US of Merrica

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List