Max said:
Well, the max number of visits (5) in a single day has decided by the boss
of the office, so it would be ok to me, too. So, it's not a problem of mine.
I don't understand why, if I have less than five visits, I don't have ID
synchronized between tables. The five tables are identicals from the
beginning, and the ID is always the same in the other tables, so every
changes in a record in one table should replicate to the others...
It will always depend on how you generate these IDs (I must warn you
that there are lots of lines of thought in this matter, every one
claiming to be the definitive one).
Personaly, I prefer having a table's ID/PK as an identity column
managed by the system (an autoincrement column, in Access), . Other
people may prefer to generate the keys themselves. Others still will
prefer to use something completely meaningless, say, a GUID, or
whatever (btw, I am, too, among the ones that think that the PK is
meant *only* to pinpoint a given record, but I prefer using a
light-weight identity column for that).
Autoincrement IDs are completely ruled out, for you. Because they're
managed by the DB engine, as soon as you have a situation with, say,
three visits only, the two other tables will become out of synch with
the other three. And it will only get worse after that.
GUIDs are ruled out also, because, while autoincrement IDs are local to
each table, GUIDs are globally unique among every table, so you can't
have the same GUID for different tables (or so it seems. Forgive me if
I'm mistaken).
Finally, your only choice seems to be to generate your own keys, or
have a mix of tables with hand-made keys and one of the tables with
auto-generated keys (but which one?). Hand generated IDs have their
charm, but have some caveats. Most importantly, their generation logic
is left to the user, instead of remaining hidden inside the DB, and
this may give rise to inconsistencies and, ultimately, warts,
dizzyness, loss of sexual performance, the hell on earth... (=))) you
see I'm *a little* biased, here).
About the visit pricing: there are more than 70 different type of medical
visits, and each one has a price.
So in a row, I have:
VisitID;
Price;
VisitType.
Just three columns.
Is this the table with information about each type of visit?
If the boss decides to change the prices of, for i.e., 45 type of medical
visits, the changes must reflect to the other four tables.
Forgive my dumbness: I still don't get it. Are these prices supposed to
change (if they ever do) for a given visit, only? Or would they change
for a whole category of visits? Or, still, would the prices change only
for a given day (a Christmass promo, for instance =))) ?
More over these 'famous' five tables, there are only three more tables:
The Patients table (just ID, and name and surname);
The Doctors table (just ID, and name and surname);
The Visit table (called by a form) would consist of:
VisitID;
Date;
Patient name;
VisitType 1...VisitType 5 (combo box; if there are less than 5 visits, the
other combo box will be blank);
Doctor's name.
That's it.
I just need to change the Price column in one table, and make automatically
the changes (update, delete or insert) in the other four tables.
It sounds simple...
<snip>
It seems you want the price to be the same for all the visits of a
given patient in a given day.
Idealy, this would call for a master/detail relation:
Visit table: VisitID, PatientID, Price, Date
VisitDetail table: VisitDetailID, VisitID (the FK), VisitType, DoctorID
Alternatively (oh, the blasphemy!), you could have:
VisitID, PatientID, Price, Date, Visit1Type, Visit1Doctor, ... ,
Visit5Type, Visit5Doctor
HTH.
Regards,
Branco.