Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent Duplicate Child Records?

Status
Not open for further replies.

fishtek

Technical User
Aug 21, 2002
56
0
0
US
I have a station ID table connected to another data (species code) table via one to many relationship using the station ID. Users enter species codes for a station using a form. How can I prevent a user from entering duplicate species codes for a particular station ID. In other words its ok to have duplicate species codes in the data table, but not for a particular station ID. Hope this is not confusing. Thanks for any help.
 
Would "one to one relationship" do the trick?

Have fun.

---- Andy
 
Create a unique index on (station ID,species code).
In fact, IMHO this should be the PK of the child table ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
3 tables.

Station Table
- StationID
- other station data
Species Table
- SpeciesID
- other species data
Station-Species Table
- StationID
- SpeciesID

This allows a species to be recorded at more than one station, but not more than once at each station. The concept is called a relation table, bridge table, and I think there are a few other names.

====================================
The reasonable man adapts himself to the world. The unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. - George Bernard Shaw


 
johnherman, the OP clearly states a one-to-many Relationship.
Your suggestion of a junction table is suitable for a many-to-many Relationship.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top