2012-07-08 53 views
1

我需要创建价格表系统,因此我要在我的数据库中创建这三个表。为定价系统创建数据库的更好方法

  • PricingTable (ID, Name, ServiceID, Style)
  • PricingTablePackages (ID, PricingTable_ID, Title, Price, PricePerTime, Info, Flag, Link)
  • PricingTablePackagesFeatures (ID, PricingTablePackages_ID, Feature, Value, MoreInfo)

在这里,人们PriceTable可以容纳一个以上的PricingTablePackages和一个PricingTablePackage可以容纳一个以上的PricingTablePackagesFeature

有什么办法可以设计出更好的模型?在单个数据库表中?

我要为这些表创建一个MVC3模型,那么在MVC3模型中做这种数据库表的最佳方式是什么?

+0

这对我很好:) – Samson 2012-07-08 09:29:41

+0

你觉得够好吗? – zxprince 2012-07-08 09:31:35

+0

那么到目前为止我还没有看到任何问题..如果你想要对表格做所有的描述,那应该没问题。 – Samson 2012-07-08 09:34:47

回答

1

当你需要他们使用实体框架,我会用公共的虚拟变量'懒加载的价值观:

(变量类型可能会关闭这取决于你想要什么,每个变量)

public class PricingTablePackages 
{ 
    public int ID { get; set; } 

    public int PricingTableID { get; set; } 

    public virtual PricingTable PricingTable { get; set; } 

    public string Title { get; set; } 

    public decimal Price { get; set; } 

    public decimal PricePerTime { get; set; } 

    public string Info { get; set; } 

    public bool Flag { get; set; } 

    public string Link { get; set; } 
} 

public class PricingTablePackagesFeatures 
{ 
    public int ID { get; set; } 

    public int PricingTableID { get; set; } 

    public virtual PricingTable PricingTable { get; set; } 

    public string Feature { get; set; } 

    public string Value { get; set; } 

    public string MoreInfo { get; set; } 
} 

public class PricingTable 
{ 
    public int ID { get; set; } 

    public string Name { get; set; } 

    public int ServiceID { get; set; } 

    public virtual Service Service { get; set; } // if there is a Service class 

    public string Style { get; set; } 
}