Foreign Key Design...
- From: "Steven" <steven.81@xxxxxxxxx>
- Date: 26 Jul 2006 19:41:03 -0700
Hello All,
I am relatively new to database design and wanted to ask a few
questions to see if I am on the right track regarding design and
normalization.
I am creating a user entity which is made up of 4 tables:
User(UserID(PK), EmpID, CountryID, PostCodeID)
Employee(EmployeeID(PK), EmployeeType)
Country(CountryID(PK), CountryName)
PostCode(PostCode(PK), CountryID(PK), City)
These are a few things I am trying to clarify
1) The Country table has a relationship with the User table via a
foreign key FKUser_CountryID, and the PostCode table has a relationship
with the User table via FKUser_PostCodeID_CountryID. I dont however
have any relationship between the Country and PostCode tables. Is this
okay or have I created these relationships incorrectly? My other
thinking was to create a location table:
Location(CountryID, PostCodeID, City)
Then the User table would have a relationship with location through the
Country and PostcodeID fields, and the Location table would have a
relationship with the Country table through the CountryID field?
2) There will be instances where the User is not an employee, so the
EmpID field will be null when no relationship exists between User and
Employee. Is it worth creating a boolean field in the User table called
IsEmployee to help checking in programs, or should I just rely on
checking whether the EmpID field is null in the User table.
3) Finally, much of the old data on the system has been created in
databases created many years ago. Unfortunately much of this old design
includes storage of redundant data, lack of constraints and no
normalization. However because many of the old programs would need to
be completely re-written if the schema of these tables were changed I
am really stuck using them. Does anyone have any advice on steps I
could take to improve the situtation.
I appreciate any help anyone can give me
Steve
.
- Follow-Ups:
- Re: Foreign Key Design...
- From: Tim Marshall
- Re: Foreign Key Design...
- From: Nick 'The Database Guy'
- Re: Foreign Key Design...
- From: pietlinden
- Re: Foreign Key Design...
- Prev by Date: Re: Move record from one table to another
- Next by Date: Re: Copy records from one database to another
- Previous by thread: Combo Box
- Next by thread: Re: Foreign Key Design...
- Index(es):
Relevant Pages
|