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.
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.