I'm currently developing a software with C# and want it to store the data in a database. My problem is that i'm looking for the best approach to store the data of an object that contains two arrays. The objects in the array look exactly the same but they got a different meaning.
As an information: The data of the objects in the data is changing regularly.
For example i got the following two classe:
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; }
}
Please note that i currently got over 24000 objects from ObjectC. The amount of objects that each array of those objects contains can vary quite a lot (up to 200 and maybe more in the future). Could this lead to any problems with the maximum row count if i use one of the solutions?
I got the following two ideas of how the database shema could look like:
All attributes in one table.
Create a coloumn for each attribute of
ObjectAandObjectBso 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
nameredundantly.Creating a foreign key in the table for ObjectA
By doing this i could avoid storing the data from
ObjectCredundantly 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`) )
Also, would it be better to create a new row in the database for each time the data of the arrays has changed, or should I change the existing data?
Edit: Added some information about the amount of objects (right below the c# example).