views:

226

answers:

2

Hi, I was recently hired at a Software Engineering company and was put in charge of a new project for storing our analytics data. I want to give ORM a shot the mapping doesn't seem difficult but this problem has me vexed.

This database will store data for Google Analytics, Quantcast, and any future analytics provider. I was pretty much given the schema that needs to be used. They want it to be very general which is possible until I store the matrices as we track different ones for each provider.

The table layout is as such:

tblClient - Stores all the client websites.
tblProfile - 1 or more belong to a client. Stores profile data such as what provider this profile is is using and the profile_type.
tblProvider - Stores data as to whether a profile is a GoogleAnalytics, Quantcast, or other analytics profile.
tblProfile_Type - The type of track for the client site. We have client sites broken down into different sections. That is tracked here.

The problem comes when I need to link the profile table to a metrix table. On this diagram I only have the one for Google but there will be others. I need it to link based on the FK column for Provider_Type in the profile table. Is that possible?

Thanks for any help.

A: 

Have a look at the "any" type mapping.

Any Type Mapping

HokieMike
A: 

If I understand correctly you have many-to-one relation between tblAny_Profile and tblAny_Provider. May be 'invert' this relationship by having one-to-many relationship between tblAny_Provider and tblAny_Profile? Such way you'll have Bag or List property in tblAny_Provider entity having many instances of tblAny_Profile entities.

The problem is creating the proper relation to Google_Metric_Set or Quantcast_Metric_Set(not showed in diagram) based on the type of profile.
Wix