July 20, 2005 at 7:10 am
As a result of a data extract I have a table that holds Patient demographic details, one row for each time a patient has been in A&E. Each row has a unique key A&E number. The A&E number was been created for each A&E visit. It also holds the A&E number from the patient’s last visit. I would like to normalize the demographics and keep the A&E numbers in a cross reference table, since they are the foreign key to a number of tables holding clinical detail regarding the visit. Are there any T-SQL tricks anyone can suggest that would help? The table in question has 400K rows.
Illustration
A&E number Full Name DOB …… Previous A&E number
P001
P003
P075
What I would like is
Patient Demographics
A&E number Full Name DOB ……
P001
Cross –reference table
P001
P001
We have Microsoft SQL version 8.
Denise
July 20, 2005 at 8:03 am
Could you post the table definition and also a list of indexes on your table?
What is "Previous A & E number" for the first visit, null or blank?
And (just curious) what is "A & E"?
July 20, 2005 at 8:17 am
Seems to me that you might not have gone far enough in your normalisation quest. I suggest that you should have something like the following tables:
Patient(PatientID, Name, DOB, etc etc)
AandEVisits(VisitID, PatientID, Date)
With your data stored in this form, you can display the data the way you want. In particular, you should not store 'previous visit id' on the same row as 'visit id'. It might make your queries a little simpler, but the ongoing maintenance burden will outweigh this.
A&E stands for Accident and Emergency.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
July 20, 2005 at 8:23 am
Also - what is the A&E number data type and how is it generated ?!
It should be possible to extract the Patient information and insert into the Patient table that Phil outlines....(with grouping by patient name and taking the min of the date part of the A& E number) -
**ASCII stupid question, get a stupid ANSI !!!**
July 21, 2005 at 1:48 am
Thank-you for the replies. Yes A&E number is Accident & Emergency. The data extract is fixed and the index is A&E number. First visit does have a null previous A&E number.
But I think you are right. Making a second table from the extract table and breaking up the date part of the number is on the right lines.
Thanks Denise
July 21, 2005 at 4:47 am
You are welcome
If you still need help, please post the table definition.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply