EF6 Model design critique

I have the models of 2 Oracle tables defined below. I’m trying to figure out if I’ve got this design correct and how to write my get, post and put methods for WebAPI2 but am kind of confused about it.

namespace TNAWA.Models
{
    [Table("CC3.WS_GK_STATE")]
    public class WsGkState
    {
        /*
        // Oracle definition
        WGS_RID	    1 NUMBER (9)
        WGS_STATE	3 VARCHAR2 (2 Byte)
        WGS_TYPE	2 NUMBER (9)
        WGS_WGT_RID	4 NUMBER (9)
        */
        [Key, Column("WGS_RID")]
        public int Id { get; set; }

        [StringLength(2), Column("WGS_STATE")]
        public string State { get; set; }

        [Column("WGS_TYPE")]
        public int GkType { get; set; }

        [Column("WGS_WGT_RID")]
        public int WsGkTextId { get; set; }

    }

    [Table("CC3.WS_GK_TEXT")]
    public class WsGkText
    {
        /* 
        // Oracle definition
        WGT_PRG_CODE VARCHAR2 (5 Byte)
        WGT_RID	     NUMBER (9)
        WGT_TEXT	 VARCHAR2 (4000 Byte)
        */

        [Key, Column("WGT_RID")]
        public int Id { get; set; }

        [StringLength(3), Column("WGT_PRG_CODE")]
        public string PrgCode { get; set; }

        [StringLength(4000), Column("WGT_TEXT")]
        public string Gk_Text { get; set; }

        // Navigation property
        public virtual ICollection<WsGkState> States { get; set; }

    }
}

This would be some dummy data:

WS_GK_STATE:
    WGS_RID,    WGS_STATE,  WGS_TYPE,   WGS_WGT_RID
          1,         "TX",         0,             1
          2,         "AK",         2,             4
          3,         "NV",         1,             3
          4,         "LA",         0,             2
          5,         "AZ",         0,             3


WS_GK_TEXT:
    WGT_RID,    WGT_PRG_CODE,   WGT_TEXT
          1,            "AO",   "This is GK Text for Texas AO"   
          2,            "CC",   "This is GK Text for Louisiana CC"   
          3,            "LH",   "This is GK Text for Nevada LH for type 1 and Arizona LH for type 0"
          4,            "FUN",  "This is GK Text for Alaska FUN"   

In the UI, the user will need to select STATE, PRG_CODE, and GK_TYPE from select controls, then they will enter the GK_TEXT in a text area.

Then the WS_GK_TEXT item will be saved and then the WS_GK_STATE.

I hope this isn’t too broad a question to ask but is this the way to build and handle related records like this? We are designing it this way to avoid multiple records in WS_GK_TEXT if the same GK_TEXT is to be used for different types or states.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.