I have an organization table like this:
OrgID | OrgInviteCode | OrgName | Status | ProjectTableName | InsertOn
-------------------------------------------------------------------------------------------
1 | RC12T67 | Organization1 | Active | Project1 | 2015-12-19 15:37:43.333
2 | BC56uI7 | Organization2 | Active | Project2 | 2015-12-19 15:37:43.333
3 | ORG1456 | Organization3 | Active | Project3 | 2015-12-19 15:37:43.333
4 | ORG2856 | Organization4 | Active | Project4 | 2015-12-19 15:37:43.333
And I have a stored procedure to create a dynamic table for project.
If any new organization is created successfully then we call the stored procedure to create the project table for that organization.
Each organization has its own project table. So the project table name is dynamic for each org and it's name stored in organization table.
Organization1 --> Project table
ProjectID | OrgID | ProjectName | ProjectInvideCode | Address1 | Address2 | City |State | ZIP | Country
-------------------------------------------------------------------------------------------------------------------------------
1 | 1 | Org1Proj1 | XJ34590 | 235 Harrison St. | | Syracuse | AK | 23456234 | US
2 | 1 | Org1Proj2 | JKI8907 | 35 Sterling St. | | Syracuse | NY | 23456456 | US
Organization2 --> Project table
ProjectID | OrgID | ProjectName | ProjectInvideCode | Address1 | Address2 | City |State | ZIP | Country
-------------------------------------------------------------------------------------------------------------------------------
1 | 2 | Org2Proj1 | RUIO90 | 90 Ram St. | | Los Angeles | CA | 23456234 | US
2 | 2 | Org2Proj2 | KLOP907 | 35 Wide St.| | Chicago | IL | 23456456 | US
I'm currently working in integrating the search feature. Users or Anonymous users may search data based on the below logic:
- Search with organization name or organization invite code.
- Search with project name or project invite code.
- Search with project address, city, state, country
I know it's very simple to find the search result for organization name and invite code, because all the content is resides in same table.
But it's more complicated to get the search result for the projects(name or invite code) due to dynamic table name. I found this link in How to fetch data from dynamic multiple tables?, so I think it's not a better solution because search needs to very fast.
The reason why we separate the project tables based on organization because in our requirement they clearly mention that "We have 1000000 organization, but each organization having more then 1 Million projects". Hope you understand the concept we don't want to dump the 1000000(Organization) * 1 Million = XXXXXX projects in single table.
Questions:
- How we can search the projects data in effective way?
- Does our project separate table concept is worst? Do you have any suggestion to handle in much better?
- Is there any effective way in C#?
Tools and Technology:
- Asp.Net 4.5, C#
- MVC 5
- Entity Framework code first
- SQL Server 2012