I need to build a UI for entering values to the database. I am stuck with my class design to achieve it.
I need a UI where I am able to enter the name of the system. Each system can have many options. Each option is associated with a TC(Technical chara). Each TC has another set of values which is described as TCset. For instance, let's say Tcset for a TC (TC1) has values: TC1.1, TC1.2, TC1.3. (There other variables describing each row in the TCset, I have mentioned the name property alone for simplicity. Now again coming back to the system, the option defined in each system can have multiple option values. For each option value I should be able to enter a value for the name property in TCset associated with the TC of that option.)
What I would like to achieve would be something similar to this.
Adding a system and defining the Options:
Adding Value for Option and value for SetVal:
Based on my understanding I have designed the following class diagram. But still I can't find the exact mapping between the Option and SetVal. I am unable to design a class where I could add values for the Tcset in a particular option
public class Lsystem
{
public int LsystemID { get; set; }
public string LsystemName { get; set; }
public virtual ICollection<Option> Options { get; set; }
public int OptionId { get; set; }
}
public class Option
{
public int OptionID { get; set; }
public string OptionName { get; set; }
public int TCID { get; set; }
public virtual TC tc { get; set; }
public virtual Lsystem Lsystem { get; set; }
public int LsystemID { get; set; }
public virtual ICollection<OptionValue> OptionValues { get; set; }
}
public class OptionValue
{
public int OptionValueID { get; set; }
public string ValName { get; set; }
//public int TCsetID { get; set; }
public int OptionID { get; set; }
public int SetValID { get; set; }
public virtual Option Option { get; set; }
//public virtual TCset TCset { get; set; }
public virtual SetVal SetVal { get; set; }
}
public class TC
{
public int TCID { get; set; }
public string TCName { get; set; }
public virtual ICollection<TCset> TCsets { get; set; }
}
public class SetVal
{
public int SetValId { get; set; }
public double Value { get; set; }
public int OptionID { get; set; }
public int TCsetID { get; set; }
public virtual OptionValue OptionValue { get; set; }
public virtual TCset TCset { get; set; }
}
public class TCset
{
public int TCsetID { get; set; }
public string TCsetName { get; set; }
public string PhysicalUnit { get; set; }
public int TCID { get; set;}
public virtual TC TC { get; set; }
}
Is there something I am missing to get it right. But the current class model doesn't work because foreign key conflicts. That made me add another class SetVal but did not solve my problem. I have tried a lot to get all the relationships right but nothing worked out.
Just for a briefing, the relationships that I have used here:
System - Option : One to Many
Option - OptionValue : One to Many
Option - TC : Many to One
TC - TCset : One to many
OptionValue - SetVal : One to One
TCset - Setval : One to One
The point where i am stuck is generating a table which would take option value id and give an option to add values for the tcset.
That is Under Option Value Ab1, i need a table to give values like the following
Option Value Ab1
ABC1 - 45 ABC2 - 34
Option Value Pq1
PQR1 - 67 Pqr2 - 34 pqr3 - 56
Option Value Pq2
PQR1 - 67 pqr2 - 34 pqr3 - 67
This connection is what i am missing. i realized this when i was trying to make tables the way it was made in the answer
Edit : 2 Adding example
+--------------------------+
| SystemId | System Name |
+------------+-------------+
| 1 | DCC - 050 |
|____________|_____________|
| 2 | DCC - 070 |
|____________|_____________|
____________________________
| TCID | TCName |
|____________|_____________|
| 1 | Screw |
|____________|_____________|
| 2 | Motor |
|____________|_____________|
__________________________________________________________
| TCSetID | TCsetname|PhysicalUnit | DataUsage | TCID |
|___________|__________|_____________|___________|________|
| 1 | speed | m/sec | Prelimina | 1 |
|___________|__________|_____________|___________|________|
| 2 | d_0 | mm | final | 1 |
|___________|__________|_____________|___________|________|
| 3 | d_1 | m | final | 1 |
|___________|__________|_____________|___________|________|
| 4 | torque | mm | final | 2 |
|___________|__________|_____________|___________|________|
____________________________________
|OptionID | SystemID | TCID |OpName |
|_________|__________|______|_______|
| 1 | 1 | 1 |Screw |
|_________|__________|______|_______|
| 2 | 1 | 2 |Motor |
|_________|__________|______|_______|
_______________________________________________
|OptionvalID | SystemID|OptionID | OptionValue|
|____________|_________|_________|____________|
| 1 | 1 | 1 | 01 |
|____________|_________|_________|____________|
| 2 | 1 | 1 | 02 |
|____________|_________|_________|____________|
| 3 | 1 | 1 | 03 |
|____________|_________|_________|____________|
| 4 | 1 | 2 | 01 |
|____________|_________|_________|____________|
| 5 | 1 | 2 | 02 |
|____________|_________|_________|____________|
Now the main issue is, i want to give values for the TCsetname in each option. My resulting table would be the following (This is not the database schema)
SCREW
__________________________________________
|TCSet | 01 | 02 | 03 | => Option values for Screw
|______|__________|__________|___________|
|speed | 12 | 14 | 16 |
|______|__________|__________|___________|
|d_0 | 34 | 56 | 56 |
|______|__________|__________|___________|
|d_1 | 2 | 5 | 6 |
|______|__________|__________|___________|
MOTOR
______________________________
|TCSet | 01 | 02 | => Option Values for the Option Motor
|______|__________|__________|
|Torqu | 12 | 14 |
|______|__________|__________|
I am looking to correct the datamodel which accepts the last table

