My question is, how can I link a reference stored in the Log
table to a piece of data in another database?
We're building a system (Called Fusion) that will perform certain key tasks for all our other systems, one of these is a logging.
The idea is that any other system will be able to use Fusion to log specific operation.
CREATE TABLE [Log]
(
[LogID] [int] IDENTITY(1,1) NOT NULL,
[UserID] [int] NOT NULL,
[LoggedOn] [datetime] NOT NULL,
[ReferenceID] [int] NOT NULL,
[ReferenceLocation] [varchar](250) NOT NULL
)
So in the simplified table design above the ReferenceID
column would store the foreign key from another database column. So the StoryID from a news database or the PersonID from a person database.
Then the ReferenceLocation
would store the database.table.column location for the ReferenceID
column.
The idea being that a SQL query could be written (using dynamic SQL or another method) so that the referenced data for each row can be returned when the Log
table is queried.
Is this the way to do it? Is there a better way? Should we re-think the reasoning behind this endeavour in general?