By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 2,094 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

How to skip integrity check while inserting record

pradeepjain
100+
P: 563
Hi,
I have a small problem.

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
May 7 '10 #1
Share this Question
Share on Google+
2 Replies


jkmyoung
Expert 100+
P: 2,057
A kind of hack I have seen would be to create a null patient for guests, eg say id 9999. Then whenever there is an unregistered patient, set their id to 9999 when inserting it into the table.

Also, sounds like you're duplicating info in your tables.
May 7 '10 #2

pradeepjain
100+
P: 563
@jkmyoung
hey to prevent the duplication of data i decided to have 1 table... but the patient Id field is auto incremented in patient data table...creating a ID 9999 in patient data table will start the auto increment from that ID ...

i will give the table structure

Expand|Select|Wrap|Line Numbers
  1. desc patient_data;
  2. +-----------------------+--------------+------+-----+---------+----------------+
  3. | Field                 | Type         | Null | Key | Default | Extra          |
  4. +-----------------------+--------------+------+-----+---------+----------------+
  5. | pd_patient_id         | int(11)      | NO   | PRI | NULL    | auto_increment | 
  6. | pd_um_id              | int(11)      | NO   |     | NULL    |                | 
  7. | pd_alternate_id       | int(11)      | YES  |     | NULL    |                | 
  8. | pd_name               | varchar(40)  | NO   |     | NULL    |                | 
  9. | pd_lastname           | varchar(40)  | YES  |     | NULL    |                | 
  10. | pd_dob                | date         | YES  |     | NULL    |                | 
  11. | pd_gender             | varchar(1)   | YES  |     | NULL    |                | 
  12. | pd_language_preferred | varchar(40)  | YES  |     | NULL    |                | 
  13. | pd_visit_reason       | text         | YES  |     | NULL    |                | 
  14. | pd_visit_reason_other | text         | YES  |     | NULL    |                | 
  15. | pd_membership_details | text         | YES  |     | NULL    |                | 
  16. | pd_address            | varchar(200) | YES  |     | NULL    |                | 
  17. | pd_landmark           | varchar(200) | YES  |     | NULL    |                | 
  18. | pd_city               | varchar(50)  | YES  |     | NULL    |                | 
  19. | pd_state              | varchar(50)  | YES  |     | NULL    |                | 
  20. | pd_pincode            | int(6)       | YES  |     | NULL    |                | 
  21. | pd_recommended        | varchar(1)   | YES  |     | NULL    |                | 
  22. | pd_recommended_by     | varchar(50)  | YES  |     | NULL    |                | 
  23. | pd_recommended_file   | blob         | YES  |     | NULL    |                | 
  24. | pd_phone              | varchar(15)  | YES  |     | NULL    |                | 
  25. | pd_alternate_phone    | varchar(15)  | YES  |     | NULL    |                | 
  26. | pd_email_id           | varchar(255) | YES  |     | NULL    |                | 
  27. | pd_alternate_email_id | varchar(15)  | YES  |     | NULL    |                | 
  28. | pd_created_date       | datetime     | YES  |     | NULL    |                | 
  29. | pd_created_by         | int(5)       | NO   | MUL | NULL    |                | 
  30. | pd_last_modified_date | datetime     | YES  |     | NULL    |                | 
  31. | pd_last_updated_by    | int(5)       | YES  |     | NULL    |                | 
  32. +-----------------------+--------------+------+-----+---------+----------------+
  33.  

and

Expand|Select|Wrap|Line Numbers
  1. desc patient_appointment;
  2. +------------------------+-----------------------------------------+------+-----+---------+----------------+
  3. | Field                  | Type                                    | Null | Key | Default | Extra          |
  4. +------------------------+-----------------------------------------+------+-----+---------+----------------+
  5. | pa_id                  | int(11)                                 | NO   | PRI | NULL    | auto_increment | 
  6. | pa_pd_patient_id       | int(11)                                 | NO   |     | NULL    |                | 
  7. | pa_name                | varchar(40)                             | YES  |     | NULL    |                | 
  8. | pa_phone               | varchar(12)                             | YES  |     | NULL    |                | 
  9. | pa_reason              | varchar(30)                             | YES  |     | NULL    |                | 
  10. | pa_datetime            | datetime                                | NO   |     | NULL    |                | 
  11. | pa_mode                | varchar(15)                             | NO   |     | NULL    |                | 
  12. | pa_um_id               | int(11)                                 | NO   | MUL | NULL    |                | 
  13. | pa_type                | varchar(20)                             | NO   |     | NULL    |                | 
  14. | pa_reported_time       | time                                    | NO   |     | NULL    |                | 
  15. | pa_status              | enum('confirmed','cancelled','no-show') | YES  |     | NULL    |                | 
  16. | pa_cancellation_reason | varchar(50)                             | YES  |     | NULL    |                | 
  17. | pa_created_date        | datetime                                | NO   |     | NULL    |                | 
  18. | pa_last_updated_date   | datetime                                | YES  |     | NULL    |                | 
  19. | pa_last_updated_by     | int(5)                                  | NO   | MUL | NULL    |                | 
  20. | pa_created_by          | int(5)                                  | NO   | MUL | NULL    |                | 
  21. +------------------------+-----------------------------------------+------+-----+---------+----------------+
  22.  

bcos i need to store patients with out ID in appointment table . so i have removed the foreign key constraint in appointment table...so if patient ID is not there in appointment table i will store the name and other details or else if ID id there he is a registered patient .

hope its correct
May 8 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.