Ian
Ian

Reputation: 34489

Mapping multiple tables to the same Type/Collection

I'm working on a little project that's designed to record a lot of data, I've estimated that I need to store about 100-150 million rows of data in my database. These rows don't contain much data but are going to have frequent inserts and I want relatively quick data retrieval (this is going to be infrequent but will require rapid aggregation of the data).

From the information I've read at these sort of sizes I need to know what I'm doing and ensure Indexes etc are set up properly. What I could do however is actually split my table of data up (into roughly 250, 500k row tables).

I guess the first question is, could someone validate that this would be a good idea? From the things I've read I believe reads/inserts should be much quicker so it seems like a logical step to take.

I was also planning on using Entity Framework for this (despite the tables being quite simple) but I'm not sure if it's possible to map the same entity to lots of different tables. I've found a number of articles on mapping two tables to the same entity. So the second question is does Entity Framework allow you to map two tables to different entities of the same type?

Upvotes: 0

Views: 120

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269493

Splitting the data into multiple separate tables is not a good idea. Databases in general and SQL Server in particular can handle large tables, even tables with hundreds of millions of rows. And, the implications of working with thousands of tables are daunting. It prevents you from setting up triggers and foreign key references. It makes security more difficult. It is daunting just to list the tables in the database.

One capability that might help you is vertical partitioning, described here. Partitions allow you to store one table in separate table spaces. This can speed queries, because only one partition may need to be read. This can speed deletes, because some deletes can be handled by dropping a partition.

Upvotes: 1

Related Questions