作为信息:数据对象的数据经常变化。
例如,我有以下两个类:
public class ObjectA
{
public string Text { get; set; }
public int Value { get; set; }
}
public class ObjectB
{
public string Text { get; set; }
public int Value { get; set; }
}
public class ObjectC
{
public string Name { get; set; }
public List<ObjectA> DetailsA { get; set; }
public List<ObjectB> DetailsB { get; set; }
}
请注意,我目前从ObjectC中获取了超过24000个对象。每个对象数组包含的对象数量可能会有很大差异(最多可达200甚至更多)。如果我使用其中一种解决方案,是否会出现任何最大行数方面的问题?
我考虑了以下两种数据库架构:
All attributes in one table.
Create a coloumn for each attribute of
ObjectA
andObjectB
so that i can store each object in the array in one row.CREATE TABLE `data` ( `data_id` INT NOT NULL, `name_a` NVARCHAR(50) NOT NULL, `text_a` NVARCHAR(100) NOT NULL, `name_b` NVARCHAR(50) NOT NULL, `text_b` NVARCHAR(100) NOT NULL, `value` INT NOT NULL, PRIMARY KEY (`data_id`) )
In this case i would store the value of
name
redundantly.Creating a foreign key in the table for ObjectA
By doing this i could avoid storing the data from
ObjectC
redundantly while having to use joins when querying the data.CREATE TABLE `data` ( `data_id` INT NOT NULL AUTO_INCREMENT, `name` NVARCHAR(50) NOT NULL, PRIMARY KEY (`data_id`) ) CREATE TABLE `details_a` ( `a_id` INT NOT NULL AUTO_INCREMENT, `text` NVARCHAR(100) NOT NULL, `value` INT NOT NULL, `data_fk` INT NOT NULL, PRIMARY KEY (`a_id`) ) CREATE TABLE `details_b` ( `b_id` INT NOT NULL AUTO_INCREMENT, `text` NVARCHAR(100) NOT NULL, `value` INT NOT NULL, `data_fk` INT NOT NULL, PRIMARY KEY (`b_id`) )