Designing a production database in T-SQL means treating the schema, the queries, and the operational rules as one design problem. The core condition that separates a production database from a working prototype is that you must assume concurrency, failure, and change: multiple sessions writing at once, instances restarting mid-transaction, and requirements shifting after deployment. SQL Server gives you the tools to handle all three—constraints, transaction isolation levels, indexing, and versioned deployment scripts—but only if you decide on them deliberately before data arrives. This guide covers a workable order of operations for a new or redesigned SQL Server database, the reasoning behind each decision, the failure modes that show up in production, and how to verify each step actually succeeded.
Set preconditions and scope before writing any DDL
Design work fails most often at the boundary, not the table. Before a single CREATE TABLE, write down four things and keep them where the team can see them.
First, workload shape. Is this database mostly transactional point reads and writes (an order system), mostly analytical scans (a reporting warehouse), or mixed? SQL Server handles all three, but the defaults differ: a transactional database wants short transactions, narrow indexes matched to lookups, and optimistic or read-committed snapshot isolation; a reporting database wants columnstore indexes, partitioned fact tables, and long-running read sessions isolated from writers. The specific decisions below follow from this answer, so an unstated workload almost guarantees a redesign later.
Second, data volume and growth. Estimate rows per year per major table, not just today's count. An index that's fine on 100,000 rows can be a liability at 100 million, and partitioning decisions only make sense against a growth curve.
Third, recovery objectives. Recovery point objective (how much data you can lose, in minutes) and recovery time objective (how long an outage can last) determine your backup strategy and, indirectly, whether you can afford bulk operations without full logging. These are business decisions; get them in writing.
Fourth, naming and schema conventions. Choose whether application objects live in dbo or in a dedicated schema, whether tables are plural, and what prefixes denote staging, audit, or archive objects. SQL Server defaults objects to dbo, and without a convention, a few years of additions produce a database nobody can navigate. Decide once, enforce in code review.
A useful check: if two engineers were handed "build the order table" independently, would their column names, key types, and constraint naming match? If not, the conventions document is missing or too vague.
Choose key types and constraints deliberately
The single most consequential decision in a SQL Server schema is the primary key type, because it propagates into every foreign key, every nonclustered index (which carries the clustering key in its leaf level), and every join.
Use narrow, ever-increasing keys for clustered indexes. An INT IDENTITY column is the conventional choice; a BIGINT IDENTITY is safer if the table could exceed about 2.1 billion rows over its life. Avoid random GUIDs as clustered keys: NEWID() generates values across the whole 16-byte space, so every insert lands on a random page, causing page splits, fragmentation, and a bloated index. If you need globally unique identifiers—for example, for distributed inserts or client-generated keys—NEWSEQUENTIALID() produces GUIDs that increase, which mitigates but does not eliminate the problem, and 16 bytes still costs more than 4 or 8 in every nonclustered index. A common compromise is a narrow clustered identity key plus a separate unique constraint on a business key or GUID column.
Separate natural and surrogate keys. The order number a customer sees ("ORD-2026-00417") is a business identifier and belongs in a uniquely constrained column, not necessarily the clustered key. Business identifiers change format, can be reissued after corrections, and are wider than integers. Keep the narrow surrogate key for storage and joins, and enforce the business identifier with a UNIQUE constraint.
Put constraints in the database, not just the application. NOT NULL, UNIQUE, CHECK, and FOREIGN KEY constraints are the last line of defense when a second application, an ad-hoc script, or a data migration touches the data. SQL Server enforces them cheaply. The performance objection to foreign keys is usually overstated; the cost of an orphaned row discovered eighteen months later is not. Name constraints explicitly (CONSTRAINT FK_OrderLine_Order FOREIGN KEY ...) so error messages and deployment scripts refer to stable names.
Choose data types at their true width. VARCHAR(50) for a name that will hold 200 characters eventually; VARCHAR(MAX) for a short description "just in case"; DATETIME (3.33 ms precision, 8 bytes) where DATETIME2(0) or DATETIME2(3) is tighter and more accurate. Money should generally be DECIMAL(19,4) or a minor-unit integer, not FLOAT. Dates should be DATE where time is irrelevant, and every timestamp column should state its time zone convention in a comment or extended property, because "create time" without a zone becomes ambiguous the day you deploy to a second region.
Build indexes from queries, not from columns
Indexes are where design meets measured behavior. The order of work matters: write the core queries first, then index for them.
1: List the top queries by frequency and criticality. For each, note the filter columns (WHERE), join columns, sort and grouping columns (ORDER BY, GROUP BY), and output columns. 2: Design the clustered index first. For transactional tables, the identity key is usually right. For tables that are almost always read by one range (WHERE TenantId = @t AND CreatedAt >= @d), a clustered index on that range can eliminate lookups entirely—but it makes inserts land in fewer hot pages, so evaluate against write rate. 3: Add nonclustered indexes for the top query shapes. A composite index on (TenantId, CreatedAt) serves filters and sorts on that pair left-to-right; column order matters, and the leading column should be the one used in equality predicates. Add included columns for output fields so the query is covered and avoids key lookups. 4: Verify with actual plans, not estimates. Run the queries against representative data volume, capture the actual execution plan, and confirm the intended index is used with a seek, not a scan. Query Store (available since SQL Server 2016) records plans over time and is the right place to watch for plan regressions after schema or statistics changes. 5: Prune. Every nonclustered index adds write cost (each insert, update, and delete maintains it) and storage. An index never used in Query Store over a full business cycle is a candidate for removal.
Two SQL Server-specific cautions. First, statistics matter as much as indexes: SQL Server estimates row counts from statistics histograms, and stale statistics on a skewed column produce bad plans regardless of index design. Ensure auto-update statistics is on and watch for tables that outgrow its sampling threshold. Second, parameter sniffing—where a cached plan built for one parameter value is reused for a very different one—is a real production failure mode; Query Store's plan forcing and the OPTIMIZE FOR hints are the standard remedies, and they should be part of the design review for any query with highly variable selectivity.
A worked index example. Suppose Sales.OrderLine has 50 million rows, clustered on OrderLineId, and the hot query is "recent lines for one customer": WHERE CustomerId = @c AND CreatedAt >= @d ORDER BY CreatedAt DESC. A nonclustered index on (CustomerId, CreatedAt DESC) INCLUDE (ProductId, Quantity, UnitPrice) turns that into a range seek plus a sort-free read. The check: capture the actual plan after loading test data at production scale; a seek with the expected row estimate and no key lookup means the index is doing its job.
Design transactions and concurrency behavior
SQL Server's default isolation level is READ COMMITTED, which uses shared locks during reads and can block writers. For a new production transactional database, the two most common deliberate choices are:
Read Committed Snapshot Isolation (RCSI), enabled at the database level with ALTER DATABASE ... SET READ_COMMITTED_SNAPSHOT ON. Readers no longer block writers; they see the last committed version. This is the default in Azure SQL Database and a sensible default for new OLTP databases, at the cost of row versioning in tempdb. Snapshot Isolation, enabled with ALLOW_SNAPSHOT_ISOLATION ON and selected per transaction. It gives repeatable reads without shared locks but introduces update conflicts that the application must handle with retry logic.
Whichever you choose, document it and design the application's retry policy around it. Deadlocks are normal in a busy database; the design question is whether the application retries (it should, for deadlock error 1205 and snapshot conflict error 3960) and whether transactions are short enough that retries are rare. A transaction that spans a user's "think time"—waiting for a form submission—holds locks and versions for seconds and is the classic cause of production blocking chains.
Write the transaction boundaries into the schema documentation: which operations must be atomic together (an order header and its lines), which can be eventual (sending a confirmation email), and what the idempotency key is for any operation a client might retry. Idempotency belongs in the design, not in a later patch, because retrofitting it means deduplicating data that has already been written twice.
Plan for growth, partitioning, and archival from day one
Production databases don't fail because of today's data; they fail at three times today's data. Three design moves handle growth without a rewrite.
Partition the large, time-ordered tables. SQL Server's table and index partitioning works on a partition scheme mapped to a partition function over a column, typically a date or a monotonically increasing key. Partitioning enables partition switching—moving a month of data to an archive table in a metadata operation rather than a delete—and can improve maintenance (rebuild one partition instead of the whole index). The important caveat: partitioning only helps queries whose predicates align with the partitioning column, and it complicates index design. Plan the partition boundaries (monthly, quarterly) against your retention requirement, and remember that a partitioned table's indexes must be aligned or explicitly non-aligned.
Design archival as a first-class process. Decide the retention period per table and the mechanism: partition switching to an archive table or filegroup, or a scheduled purge in small batches (deleting millions of rows in one transaction bloats the log and blocks). The purge job needs its own monitoring, because a silently failing purge is a disk-full incident in slow motion.
Keep the log and tempdb in mind. Every large operation is bounded by transaction log throughput; bulk inserts, index rebuilds, and large updates generate log that must be backed up or truncated. If the database uses the full recovery model (appropriate when you have a recovery point objective measured in minutes), log backups must run on schedule. Tempdb sizing matters more with RCSI and with large sorts and hash joins; the design review should note the expected concurrency and any queries that spill.
Write deployment scripts that are rerunnable and versioned
The schema is code, and in SQL Server it should be deployed the same way the application is: from version-controlled scripts, through a repeatable process, with the same script applied identically to test and production.
Structure the repository as a baseline plus migrations. The baseline creates the schema as of a known version; each subsequent migration is a numbered, forward-only script (0007_add_order_status.sql) that transforms the schema from version N to N+1. Every script must be idempotent or guarded so a failed run can be retried safely—check for object existence before creating, wrap multi-statement changes in a transaction where SQL Server supports it (most DDL is transactional), and fail loudly with THROW rather than continuing silently.
A rerunnable pattern for a new column:
Deployment checks: the script runs twice without error on a restored copy of production; the resulting schema matches the expected model (a schema comparison tool or a checksum of object definitions); and the application's integration tests pass against the migrated database, not just a fresh one. The most common production deployment failure is a script that works on an empty database and fails on a populated one—adding a NOT NULL column without a default to a table with rows, or adding a unique constraint over data that turns out to have duplicates. Test on a restored copy at realistic volume.
Separate the application's database identity from administrative access
Production design includes security, and in SQL Server the practical structure is: the application connects with a login mapped to a database user that has only the permissions it needs (typically db_datareader, db_datawriter, and EXECUTE on its procedures—not db_owner), while administrative access is separate and restricted. Use contained database users where possible so the application's credentials don't depend on server-level logins, and avoid granting db_owner to anything that isn't a deployment process.
Stored procedures are a design choice, not a default. If the application issues ad-hoc SQL, parameterize everything (no string concatenation into SQL) and keep the query shapes stable so plans cache usefully. If the application uses procedures, that centralizes the query shapes and makes plan and permission management easier, at the cost of a second codebase to version. Either way, the database user's permissions should match the choice: a procedure-based application doesn't need table-level write grants.
Instrument the design so operations can see it
A production database needs three monitors from the first day: Query Store for plan and query performance history, an alert on log and data file growth against the volume's capacity, and a job that reports failed or long-running scheduled tasks (backups, index maintenance, purges). Extended Events sessions can capture deadlocks and long-running queries with far less overhead than the deprecated Profiler. The design review should state, per major table, what "healthy" looks like (row growth rate, index fragmentation thresholds that trigger a rebuild or reorganize, backup age) and who gets paged when it isn't.
Success check for the whole design: restore a backup to a fresh instance, run the deployment scripts from the baseline, run the core query set against representative data, and confirm Query Store shows the intended plans and no scans on the hot paths. If that rehearsal passes on a machine that isn't production, the design is deployable. If it only passes by hand on the original server, it isn't.
How to know the design is done, and where it breaks
The design is complete when four things exist in version control and in the running database: the schema with named constraints and documented conventions, the index set justified against actual plans, the transaction and isolation policy with the application's retry behavior, and the deployment and archival scripts tested on populated data. The remaining work is operational—monitoring, capacity, and iteration—not design.
The failure modes to watch for are specific and predictable. Random clustered keys cause fragmentation and write amplification. Foreign keys omitted "for performance" produce orphans. Indexes added per-column rather than per-query produce scans and maintenance overhead. Long-running transactions cause blocking chains under RCSI and deadlocks under locking reads. Schema changes applied by hand cause drift between environments that surfaces during the next deployment. None of these require exotic tools to detect; they require the design decisions above to be made early and the verification steps to be run before data volume makes them expensive to reverse.