Subject | Re: [IBO] Help needed. |
---|---|
Author | Svein Erling Tysvær |
Post date | 2001-04-27T08:45:10Z |
Hi Ricardo!
Are you just new to IBO, or to databases and database design in general? If
I'm guessing right, you're really talking about several different tables -
e.g. something like
Table Doctors
ID Integer Primary Key
Name String
Address String
Table Patients
ID Integer Primary Key
Name String
Address String
Table Appointments
ID Integer Primary Key
Doctor_ID Integer
Patient_ID Integer
AppointDate Date
(if you know the date, you can calculate the day in your program)
AppointTime Time
(if your not using Interbase 6 or Firebird with dialect 3, this field would
also have to be Date)
Then you can write SQL like
SELECT D.ID, D.Name, P.ID, P.Name, A.ID, A.AppointDate, A.AppointDate
FROM Appointments A
JOIN Doctors D ON D.ID=A.Doctor_ID
JOIN Patients P ON P.ID=A.Patient_ID
WHERE D.Doctor_ID = :Doctor_ID
AND A.AppointDate BETWEEN :FromDate AND :ToDate
to see the schedule of a particular doctor for a particular time period.
Sorry if I'm underestimating your knowledge of SQL and relational database
design.
Set
Are you just new to IBO, or to databases and database design in general? If
I'm guessing right, you're really talking about several different tables -
e.g. something like
Table Doctors
ID Integer Primary Key
Name String
Address String
Table Patients
ID Integer Primary Key
Name String
Address String
Table Appointments
ID Integer Primary Key
Doctor_ID Integer
Patient_ID Integer
AppointDate Date
(if you know the date, you can calculate the day in your program)
AppointTime Time
(if your not using Interbase 6 or Firebird with dialect 3, this field would
also have to be Date)
Then you can write SQL like
SELECT D.ID, D.Name, P.ID, P.Name, A.ID, A.AppointDate, A.AppointDate
FROM Appointments A
JOIN Doctors D ON D.ID=A.Doctor_ID
JOIN Patients P ON P.ID=A.Patient_ID
WHERE D.Doctor_ID = :Doctor_ID
AND A.AppointDate BETWEEN :FromDate AND :ToDate
to see the schedule of a particular doctor for a particular time period.
Sorry if I'm underestimating your knowledge of SQL and relational database
design.
Set