Python - SQl query

Soldato
Joined
22 Nov 2007
Posts
4,209
Hi All

I’ve beeb making a doctor/patient appointment booking app. I have an appointment table with patient/doctor id as foreign keys, i have an admin screen where appointment details can be entered (date, time, doctor name).

I will have a drop down to display the doctor names populated with a select statement. I can’t figure out how this will work if there are two doctors with the same name when doing the sql insert( insert doctor id into appointments where doctor name = doctor id)

this is a personal project as i’ve recently finished a udemy python course fyi
 
Natural keys are almost always a bad idea. Best to use either a guid ( so you can know the key in advance of insert ) or a self incrementing int.
A Dropdownlist Option can have an id attribute. Use that to hold your id for the doctor and show the name as content.
Doesn't then matter how many Dr Smiths you have.

I do use an auto incrementing int for the primary key
 
Back
Top Bottom