Assume a case where multiple entities all implement a shared interface. For convenience and normalization, the data associated with this interface is stored in a single, separate table.
Normally, if multiple parent tables were to stored records in this child table, we would use one mapping table per parent as an intermediary. But what if each record is unique, and not shared between the parent tables?
In this case we can use GUIDs to associate the co-located data with the correct parent.
create table Lesson
(LessonGUID uniqueidentifier not null default newid(),
title varchar(50),
primary key (LessonGUID ))
go
create table Course
(CourseGUID uniqueidentifier not null default newid(),
title varchar(50),
primary key (CourseGUID ))
go
/*
ParentEntityGuid can store a GUID from either the Lesson or Course table. This creates an implied, but not explicit, foreign key relationship to two parent tables. As the GUIDs should be unique, the data can be co-located in the table without conflict.
*/
create table LearningObjective
(LearningObjectiveGUID uniqueidentifier not null default newid(),
ParentEntityGUID uniqueidentifier not null,
ObjectiveText varchar(500) not null,
primary key (LearningObjectiveGUID)
)
go
Ignoring the question of whether this is good or bad database design, can LLBLGen handle this situation with the autogenerated entities or manual manipulation within the GUI?
Or do we have to use a stored procedure to manage the retrieval of Lesson or Course specific records from the LearningObjective table?