I have the following tables in SQL Server 2005
ReceiptPoint: ID (PK), Name
GasIndexLocation: Location (PK)
ReceiptPointIndexLocation: ReceiptPointId (FK), IndexLocation (FK), StartDate, EndDate
On any given day, a ReceiptPoint can be mapped to 1 or more IndexLocations. I need to be able to, for a given day, see what IndexLocations are being compared against. For a ReceiptPoint with multiple IndexLocations, it should show up as some kind of delimited list (for displaying to a user).
I have two problems with this.
1) ReceiptPointIndexLocation has no primary key, currently. Is the best way to handle this to just add a incrementing index field on to the table?
2) How can I get the list of IndexLocations used on a given day? From what I can tell, it would require using a non-existent string concatenation aggregate function.
Is there a totally different way I should go about organizing my data? This is still in the development stage, so I’m open to changing it.
1) The primary key for ReceiptPointIndexLocation should be all four columns. However, this wouldn’t stop entries with overlapping dates for the same location and receipt. There’s no need for an identity column when you can identify rows with a composite key.
2) SQL: