First I will describe my application and what you can do with it, then I will show you the technical relations between my entities at the end comes the question of course.
My applications workflow:
1.) A user can create a “ReleaseVersion” object and give it a name like “MyApp_v7.5.0.132”.
2.) For this ReleaseVersion he will create a Template with a name like “BookingTest” which consists of a many OrganisationUnit objects (hierarchical structure) where each OrganisationUnit can have many TemplateTeststep objects.
3.) A TemplateTeststep object consists of these fields:
a) PreCondition
b) Teststep
c) ExpectedResult
4.) After he created the Template object he is creating a Testplan object basing on the former created Template.
5.) A Testplan SHOULD display in the userinterface the same OrganisationUnits but instead of the TempalteTeststep objects I need to display additional fields which are related ONLY to the Testplan named:
d) Error/Exception
e) TestStatus
So in the Testplan there is the OrganisationUnit TreeView and a DataGrid with the 5 fields a,b,c,d,e.
5.)
When I click the save Testplan button the fields a,b,c are updated with the fields belonging to the Template.
When I click the save Testplan button the fields d and e are updated with the fields belonging to the XXX.
The unknown component is XXX. I already thought about a table named “TestplanTeststep” with 2 fields.
But to which other table should this be related?
Above all I have to be very carefull, that a TemplateTeststep and a TestplanTeststep has the same Id when I save them to database and retrieve them the next time else I could mix up data.
Thats the entity relation “description” so far:
1 ReleaseVersion has N Testplan (that seems right to me because a Testplan is only valid for a certain ReleaseVersion)
N Testplan has M Unit (here is something wrong)
1 Unit has N TestplanTeststep (here is something wrong)
1 Template has N Testplan (that seems right to me because a Testplan can not belong to another Template, after its creation its used in no other context as just open it)
1 Template has N Unit (that seems right to me because a certain UnitId can`t be used in another template no need for it, every template has its own tree/OrganisationUnit data)
1 Unit has N TemplateTeststep (that seems right to me because these 3 fields a,b,c belong to a certain UnitId and in the TreeView are only the OrganisationUnits loaded related to the Template of a Testplan)
Final question:
What needs to be done in my entity relations that all makes sense?
The stupid thing is the separation of the TemplateTeststep and the TestplanTeststep because they could be actually ONE object or ONE table. But then I would save lots of duplicate data with the fields a,b,c which are the same for every template thus for every Testplan too.
The main question I see here is: If each template has TemplateTeststeps, but each of those can also feature as a part of a TestPlan, how do we track the results? It looks like you’re considering letting each TestPlan hold a copy of those TestSteps, with extra result fields, but that’s not the way to go.
The way I’d handle this is with a many-to-many table (foreign keys to TestPlan and to TemplateTeststep) that also holds these extra result fields (Error and TestStatus). So you’re not duplicating the info about the test step (fields a-c), but you do get an opportunity to put each of those steps into many TestPlans and record their results.