sqldatabase-designdatabase-schema

Use of SQL Schema


We have number of tables which require grouping.

Example:

Each type (Domestic and International) require different set of fields so we have to create individual database tables for them.

Is it better use schema and create tables as:

Schema: Domestic 
Tables: Domestic.Product, Domestic.Order, International.Product, International.Order

or use:

Schema: dbo 
Tables: dbo.DomesticProduct, dbo.DomesticOrder, dbo.InternationalProduct, dbo.InternationalOrder

Solution

  • There's no technical reason to prefer one over the other, but the most common practice would be to use different tables in the same schema for DomesticProduct and InternationalProduct. Reserving separate schemas for either larger groupings of entities, EG Production.InternationalProduct and Production.DomesticProduct, or different areas of concern, like admin.UserSecurity, or export.vSalesSummary.