I have a small prob开发者_如何转开发lem.
I am creating an appointment table where in the foreign key is patient id which is referenced from patient table.This table is for all registered patients.
there will be unregistered patients also, who will be seeking appointments.SO i just need to store the name,phone and few details.
I don't want to make these 2 as different tables.
So is there a way to skip the integrity check of foreign key when i ma inserting unregistered patient data
Create a new patient id for unregistered patients. Use a column to mark whether a patient is unregistered: patient_registered ENUM( 'yes', 'no' )
Alternatively, allow for NULL values in your patient_id
column, and use NULL as the value for each patient row that refers to an unregistered patient.
Make the patient_id column nullable in the appointment table.
You could also have an "unregistered patient" record in the patients table and use that every time you need to add an unregistered patient if you wish to avoid NULLs.
精彩评论