Would be good to hear you guys out about how best to consider the indexing strategy, because the data in these tables may grow tremendously in the time to come. Decided to proceed by storing multi-tenant data in a single table approach. For an example, I have only couple of tables for this discussion.
CREATE TABLE [dbo].[TenantID](
[TenantID] [smallint] IDENTITY(1,1) NOT NULL,
[TenantName] [varchar](128) NOT NULL
)
CREATE TABLE [dbo].[MenuType](
[MenuTypeID] [int] IDENTITY(1,1) NOT NULL,
[TenantID] [smallint] NOT NULL,
[MenuTypeName] [varchar](128) NOT NULL
)
- MenuTypeName should be unique for each Tenant. Therefore, I will have a Unique Index on TenantID and MenuTypeName
- TenantID should be referenced to Tenant table. So, Foreign Key on TenantID.
- Am still thinking whether I should have Primary Key or just a Clustered Index on MenuTypeID which is an auto-increment column.
- In future, when the table size grows I should be able to Partition out the data based on TenantID easily to a new database server.
Questions:
- Do I really need to define the Primary Key on MenuTypeID because we know SQL Server guarantees incremental seeds. Can I just define a Clustered Index on MenuTypeID.
- Define Unique Key on TenantID and MenuTypeName.
Using this approach, I will not have primary key concept in the table design. But, I would like to hear whether am I inviting trouble in future by not having primary key in the tables?