Unix Technical Forum

Query Question

This is a discussion on Query Question within the SQL Server forums, part of the Microsoft SQL Server category; --> I'd appreciate any help please. I'm designing 3 tables Employee, Dependant, & Claim for insurance purposes. An Employee can ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 07:44 AM
wackyphill@yahoo.com
 
Posts: n/a
Default Query Question

I'd appreciate any help please.

I'm designing 3 tables Employee, Dependant, & Claim for insurance
purposes. An Employee can have multiple Dependants and claims. (The
employee owns the insurance)

I thought it might be a good idea to have a claim have a foreign key to
Employee.ID. This is fine but I'd also like to know if the claim was
for the employee's dependant instead of the employee himself.

So is this a good idea? Add a field in claim called dependantID too.
And if its NULL the claim was for the employee if not the claim was for
the dependant w/ id = claim.dependantID.

If this is a good idea, how would you make a stored procedure that
queried all claims and displayed the name of the person who the claim
was for (Which could come from the Employee or Dependant table)?

I'm trying to do this is a stored procedure so a crystal report or
program doesn't need to deal w/ the logic.

Thanks for any help.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 07:44 AM
Stu
 
Posts: n/a
Default Re: Query Question

Instead of an Employee and a Dependant table, how about a Claiment
(sp?) table that contains both; you could then do a self-join to
determine the relationship between Employees and Dependants. At it's
simplest, a Claiment table would have the following characteristics:

ID: a uniqueidentifier
Name: obvious
DependantOf: indicates that this record is a dependant of some other
claimant
PolicyHolder: used to indicate that the record holds the policy

Your claim table then would only have to look in one place to get the
ClaimentID for each Claim.

Does that make sense?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 07:44 AM
wackyphill@yahoo.com
 
Posts: n/a
Default Re: Query Question

It does make sense. The reason I didn't do that was because I'd end up
w/ redundant info. Dependants don't really need to repeat the policy
info that could all be stored in a single employee record. Any change
to the employee would have to be replicated in all dependants.

This can be done of course. And maybe its the way to go. I just didn't
think it was very normalized. You think this way is better though?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 07:45 AM
Stu
 
Posts: n/a
Default Re: Query Question

Without knowing what all of the entities are, it's hard to tell. You
have a lot of options, though:

1. I'm assuming that your policy information is split out into a
seperate table, so the only redundant info would be the key column
(which could be null for your dependants, since they don't really have
policies).

2. You could do a 1 to 1 join between your claiment table and an
employee or dependent tables. These extra tables would hold
information that is only relevant to each of these entities (e.g,, your
claiment table talks about who the claim is for, but the employee table
gives information about when the employee was hired, etc).

3. You could keep the seperate tables, and build a view for claiment.
You could then use the view as a lookup tool to get the information you
needed for your stored procedure.

Just bouncing around some ideas.
Stu

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:19 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com