Hi!
I have a problem with tracking unique ids through several tables in a database. This a DB that I am modifying which all ready had existing data.
These unique ids are unique animals that can have several things (4 in 2 general categories) happen to them.
1. The first 2 in order to have an id number assigned they can be processed and tagged. Processed means they have biological information collected on them and during this process they may or may not be tagged and tattooed. Tagged and tattooed animals are the only animals we have an interest in tracking. An animal may be caught and processed many times. They may also have the tag and tattoos numbers changed many times. And they may be caught and processed for 2 reasons – They are a nuisance, or as part of a scientific study. I have 2 tables to represent these activities:
- tblprocessing
PK idnprocessid
-tbleartags
PK idnTagId
2. The animal can also be killed either 1) as part of the hunting harvest or 2) as a result of a miscellaneous (ie hit by car). This obviously can only happen once to an animal but we do not have a kill record for every animal that was tagged. This is split into 2 tables:
- tblHarvestKill
PK idnHarvestID
-tblMiscKillI
PK idnMiscKillID
I have created a 5th table tblBears which assigns a unique id number to each bear that was processed. I have included a screen capture (very poor image quality- sorry but it was the only way to make it small enough)of the relationship window with these 5 tables to hopefully clarify the current relationships. There are as you may guess several problems:
1. Users need to be able to look up a bears ear tag or tattoo number and get a report that details all the processing events and when and how it was killed. Right now this does not work because currently tblEartags has a many to many relationship with tblprocessing, tblharvestkill and tblMiscKill and tblBears does not and cannot serve as a linking table (because it must store one unique id for an animal).
2. As you’ve probably noticed that the relationship between tblbears, tblHarvestkill and tblemiscKIll should be a one to one (since an animal cannot be killed more than once) but it is not serving as this because not every kill record is for a tagged and therefore tracked bear.
This is all complicated by the fact that we don’t have perfect data. For example: we have no processing info for some tagged bears (they may have been tagged in another state) and we need to have a record of that tag number but it has no associated processing record. So eartags must go in their own table.
I have been working on this for months and though I have diagrammed and drawn pictures and wracked my brain I am at a loss. I think I may have spent too much time staring at it and I am hoping some fresher and more expert eyes than mine may have a fix (potentially quite obvious) for this.
Any ideas are welcome. Thanks in advance for any advice. I can provide more details if needed. Sorry for writing a book.
Stephanie
I have a problem with tracking unique ids through several tables in a database. This a DB that I am modifying which all ready had existing data.
These unique ids are unique animals that can have several things (4 in 2 general categories) happen to them.
1. The first 2 in order to have an id number assigned they can be processed and tagged. Processed means they have biological information collected on them and during this process they may or may not be tagged and tattooed. Tagged and tattooed animals are the only animals we have an interest in tracking. An animal may be caught and processed many times. They may also have the tag and tattoos numbers changed many times. And they may be caught and processed for 2 reasons – They are a nuisance, or as part of a scientific study. I have 2 tables to represent these activities:
- tblprocessing
PK idnprocessid
-tbleartags
PK idnTagId
2. The animal can also be killed either 1) as part of the hunting harvest or 2) as a result of a miscellaneous (ie hit by car). This obviously can only happen once to an animal but we do not have a kill record for every animal that was tagged. This is split into 2 tables:
- tblHarvestKill
PK idnHarvestID
-tblMiscKillI
PK idnMiscKillID
I have created a 5th table tblBears which assigns a unique id number to each bear that was processed. I have included a screen capture (very poor image quality- sorry but it was the only way to make it small enough)of the relationship window with these 5 tables to hopefully clarify the current relationships. There are as you may guess several problems:
1. Users need to be able to look up a bears ear tag or tattoo number and get a report that details all the processing events and when and how it was killed. Right now this does not work because currently tblEartags has a many to many relationship with tblprocessing, tblharvestkill and tblMiscKill and tblBears does not and cannot serve as a linking table (because it must store one unique id for an animal).
2. As you’ve probably noticed that the relationship between tblbears, tblHarvestkill and tblemiscKIll should be a one to one (since an animal cannot be killed more than once) but it is not serving as this because not every kill record is for a tagged and therefore tracked bear.
This is all complicated by the fact that we don’t have perfect data. For example: we have no processing info for some tagged bears (they may have been tagged in another state) and we need to have a record of that tag number but it has no associated processing record. So eartags must go in their own table.
I have been working on this for months and though I have diagrammed and drawn pictures and wracked my brain I am at a loss. I think I may have spent too much time staring at it and I am hoping some fresher and more expert eyes than mine may have a fix (potentially quite obvious) for this.
Any ideas are welcome. Thanks in advance for any advice. I can provide more details if needed. Sorry for writing a book.
Stephanie