Constraint Naming in SQL
Introduction
Constraint naming means assigning clear, deliberate identifiers to database rules instead of accepting unpredictable system-generated names. A name does not alter what a constraint enforces, but it changes how easily people and tools can understand, modify, monitor, and troubleshoot that rule.
CREATE TABLE employees (
employee_id BIGINT NOT NULL,
employee_number VARCHAR(30) NOT NULL,
CONSTRAINT pk_employees
PRIMARY KEY (employee_id),
CONSTRAINT uq_employees_employee_number
UNIQUE (employee_number)
);
The names immediately identify the primary key and the protected business key. They become stable handles for schema operations and meaningful signals in database errors.
What Is a Constraint Name?
A constraint name is a schema identifier attached to a PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, or supported DEFAULT rule. It identifies the rule itself, not the column or index that may support it.
CONSTRAINT pk_customers
PRIMARY KEY (customer_id)
Here, pk_customers is the identifier. The database uses it when reporting, altering, or dropping the constraint.
Why Names Matter
A useful name answers three questions: what type of constraint is this, which table owns it, and what key, relationship, or invariant does it protect? That context reduces the time required to understand an unfamiliar schema.
Names also support deterministic migrations, clean schema comparisons, structured logging, monitoring, and reliable incident diagnosis. They are operational metadata, not decoration.
Anonymous Versus Explicit Constraints
CREATE TABLE customers (
customer_id BIGINT PRIMARY KEY,
email VARCHAR(254) UNIQUE
);
This is valid, but the DBMS may create identifiers such as SYS_C008924 or another vendor-specific value. The identifier can differ between environments.
CONSTRAINT pk_customers PRIMARY KEY (customer_id),
CONSTRAINT uq_customers_email UNIQUE (email)
Explicit names make intent and future DDL predictable.
Names as Executable Documentation
CONSTRAINT chk_orders_total_nonnegative
CHECK (total_amount >= 0)
The identifier states the invariant in language that reviewers, support teams, and application developers can recognize. The SQL expression remains authoritative, while the name provides a concise explanation.
Standard Constraint Prefixes
A common convention uses pk_ for primary keys, fk_ for foreign keys, uq_ for unique constraints, chk_ for checks, and df_ for named defaults. Some organizations prefer uk_ for UNIQUE.
The exact letters matter less than consistency. A documented convention should let a developer predict names without searching the catalog.
A Practical Naming Formula
<type>_<owning_table>_<role_or_rule>
Primary keys usually need only type and table because a table has one primary key. Other constraints need a role, column, business key, or invariant that distinguishes them.
Use the shortest name that remains clear and deterministic. A name is a label, not a copy of the entire SQL expression.
Primary Key Naming
A straightforward pattern is pk_<table>, such as pk_customers, pk_orders, or pk_order_items.
CREATE TABLE customers (
customer_id BIGINT NOT NULL,
CONSTRAINT pk_customers
PRIMARY KEY (customer_id)
);
Adding the key column to the name is usually unnecessary because the table can have only one primary key.
Composite Primary Key Naming
A composite primary key is still one primary key, so pk_enrollments is normally sufficient even when it includes student and course columns.
CONSTRAINT pk_enrollments
PRIMARY KEY (student_id, course_id)
A standard based on table identity remains stable if the implementation later adds another key component.
Unique Constraint Naming
For a simple business key, use a pattern such as uq_customers_email or uq_orders_order_number. The table and key are visible without inspecting the DDL.
CONSTRAINT uq_customers_email
UNIQUE (email)
Avoid generic identifiers such as unique1 or uq_value, which provide no ownership or business context.
Composite UNIQUE Naming
A two-column tenant rule can be named by columns, as in uq_users_tenant_username, or by a stable business concept such as uq_users_scoped_username.
CONSTRAINT uq_users_tenant_username
UNIQUE (tenant_id, username)
Choose one project-wide approach. Column-based names are deterministic; semantic names can remain shorter when combinations become large.
Foreign Key Naming
Foreign keys belong to the child table, so place the child first and describe the relationship role: fk_orders_customer, fk_order_items_product, or fk_payments_invoice.
CONSTRAINT fk_orders_customer
FOREIGN KEY (customer_id)
REFERENCES customers(customer_id)
The identifier reads naturally as the customer relationship owned by orders.
Multiple Foreign Keys to One Parent
When two columns reference the same parent, the parent name alone is ambiguous. A transfer can have from-account and to-account relationships; an order can have billing and shipping addresses.
CONSTRAINT fk_transfers_from_account
FOREIGN KEY (from_account_id) REFERENCES accounts(account_id),
CONSTRAINT fk_transfers_to_account
FOREIGN KEY (to_account_id) REFERENCES accounts(account_id)
Role-specific names make errors and reviews unambiguous.
Self-Referencing Foreign Keys
A self-reference should also describe its role. For an employee hierarchy, fk_employees_manager is more informative than fk_employees_employee.
Other useful roles include parent, supervisor, predecessor, replacement, and category parent. Use terms from the domain rather than technical positions.
Composite Foreign Key Naming
A composite relationship does not always need every column in its name. fk_inventory_warehouse can clearly represent a company-and-warehouse relationship if the schema makes that scope obvious.
List components only when doing so distinguishes the relationship. Excessively long generated names are difficult to type and may exceed DBMS limits.
CHECK Constraint Naming
CHECK names should describe the invariant or valid outcome, not merely say that a value is checked. Prefer chk_products_price_nonnegative over chk_products_price when the boundary matters.
CONSTRAINT chk_projects_date_range
CHECK (end_date IS NULL OR end_date >= start_date)
The name captures the date-range concept without duplicating every operator.
Business Meaning Versus SQL Syntax
chk_orders_total_nonnegative states the outcome, while chk_orders_total_gte_zero mirrors the expression. Both are understandable, but outcome-oriented names often communicate better during incidents.
Use exact language. If zero is allowed, do not call the rule positive. A misleading name creates documentation drift.
Conditional CHECK Names
CONSTRAINT chk_orders_shipped_timestamp
CHECK (
status <> 'SHIPPED'
OR shipped_at IS NOT NULL
)
This name describes the relationship between state and timestamp. Closely related conditions can remain one logical rule, while unrelated validations should usually have separate checks for clearer diagnostics.
DEFAULT Constraint Naming
Named defaults are especially relevant in SQL Server, where a default can be a separately managed schema object. A common pattern is df_<table>_<column>.
status VARCHAR(20)
CONSTRAINT df_orders_status DEFAULT 'PENDING'
A predictable identifier makes later replacement or removal easier than discovering a generated name first.
NOT NULL Naming
NOT NULL is commonly declared as a column property and is not named uniformly across database products. Do not force a convention that the target DBMS does not naturally support.
The overall naming standard should distinguish portable principles from vendor-specific syntax and catalog behavior.
Constraint Name Scope
Identifier uniqueness can be enforced per table, schema, or another namespace depending on the DBMS and constraint type. Verify the target platform before adopting short generic names.
Including the owning table usually avoids collisions and makes catalog searches, logs, and deployment scripts easier to interpret even where broader uniqueness is not required.
Identifier Length Limits
Database engines impose different maximum identifier lengths. A convention that lists schema, table, every column, parent table, and action can be truncated or rejected.
Define a deterministic fallback for long names. Use stable abbreviations or a short hash only when tooling needs it, and preserve human-readable ownership and role near the beginning.
Case, Quoting, and Portability
Lowercase snake case is widely readable and avoids quoted mixed-case identifiers. Names containing spaces or special characters require quoting and complicate scripts.
Prefer letters, digits, and underscores; avoid reserved words. Follow the project's established table convention rather than mixing singular, plural, snake case, and camel case arbitrarily.
Deterministic Names
The same schema definition should produce the same name in development, test, staging, production, and every shard. Determinism supports repeatable deployment and reliable drift detection.
Do not embed developer names, ticket numbers, timestamps, or temporary project codenames. Constraint names should derive from stable schema meaning.
Dropping and Replacing Constraints
ALTER TABLE orders
DROP CONSTRAINT fk_orders_customer;
Syntax varies by engine, but many changes require the existing name. Explicit naming makes a change from one delete action or validation rule to another straightforward and consistent across environments.
Why Generated Names Complicate Migrations
A generated identifier may differ between fresh installations and long-lived databases. A migration that hard-codes one environment's name can fail elsewhere, while a discovery query adds vendor-specific complexity.
Explicit names make forward migrations, rollback scripts, and fix-forward procedures easier to review and automate.
Constraint Names in Error Messages
A violation of uq_users_tenant_username is immediately recognizable as duplicate username scope. A violation of SYS_C005673 requires a catalog lookup before diagnosis can begin.
Readable names reduce incident time and help developers connect database protection to the domain behavior that triggered it.
Application Error Mapping
Drivers may expose SQLSTATE, vendor codes, constraint names, or structured diagnostics. Use the general code to identify violation type and the constraint identifier to select a specific business response.
Do not depend only on substring matching of localized error text. Treat the database name as structured metadata where the driver provides it.
Protect Internal Schema Details
Raw identifiers can reveal table names, columns, tenant strategy, and business rules. Public clients should receive a safe message such as “That email is already registered for this account,” not an internal SQL exception.
Keep detailed names in secured logs and observability systems, with sensitive values redacted.
Logging and Monitoring
Structured logs can record constraint=uq_api_requests_client_idempotency along with service, operation, release, and tenant identifiers. Metrics can count violations by constraint without storing confidential data.
A sudden increase may reveal duplicate messages, incorrect retries, bad ingestion order, or a deployment that changed normalization behavior.
Constraint Names as Operational Signals
A repeated foreign-key failure can indicate synchronization lag, while repeated CHECK failures may expose upstream data-quality regression. The name turns a low-level exception into a recognizable signal.
Monitoring should lead to correcting writers or workflows, not casually removing the database protection.
Schema Review Benefits
Consistent names make missing, duplicate, incorrectly scoped, or ambiguous constraints easier to spot in pull requests. Reviewers can infer the expected constraint map before reading every expression.
Naming cannot repair a wrong model. First establish the correct business rule and constraint; then assign the name that explains it.
CI/CD and Schema Drift
Deterministic names reduce noisy schema differences between environments. Deployment tools can distinguish a true rule change from an automatically generated identifier difference.
This improves automated validation, rollback preparation, reproducible test databases, and fleet-wide checks across shards or tenant databases.
ORM and Migration Frameworks
Hibernate, Entity Framework, Django, Rails, Liquibase, and other tools can generate constraint identifiers. Their defaults may be technically valid but opaque or unstable when models change.
Configure explicit names for important rules where supported, and inspect generated DDL. Database-first and code-first workflows should produce equally understandable final metadata.
Constraint Names and Index Names
A constraint and an index are distinct schema concepts even when the database uses a unique index to enforce PRIMARY KEY or UNIQUE. A practical standard may reserve pk_, uq_, and fk_ for integrity while using ix_ for performance indexes.
Naming a business rule as a constraint communicates intent more clearly than treating every unique requirement as an indexing decision.
One Logical Rule per CHECK
Separate unrelated checks so each failure identifies a precise invariant. Price, stock, and discount range can have distinct names and error mappings.
Keep conditions together when they form one inseparable rule, such as start and end date consistency. Splitting one invariant into arbitrary fragments can be as confusing as one giant check.
Names That Survive Refactoring
A semantic name such as chk_orders_status_valid can survive a change in the allowed value list. Names based on temporary implementation details become stale when the rule moves to a reference table or changes expression.
When meaning changes substantially, rename the constraint deliberately. Do not preserve a historical identifier that now describes the wrong boundary.
Table Renames and Operational Contracts
After renaming customers to clients, pk_customers may become misleading. Renaming it improves coherence but can affect migrations, monitoring, error maps, and documentation.
Treat widely consumed constraint names as semi-stable operational interfaces. Evaluate the blast radius and deploy coordinated updates rather than making cosmetic changes casually.
Business-Key Names
For long composite rules, a business concept can be clearer than listing every column. uq_invoices_business_number or uq_shipments_tracking_identity can remain concise and meaningful.
Document the mapping in DDL and schema standards so the name remains deterministic enough for automation and understandable to new maintainers.
Large Schemas and Multiple Teams
Predictability becomes more valuable as a database grows to hundreds of tables and thousands of constraints. A shared convention reduces cognitive load across development, QA, operations, and analytics teams.
Schema or service prefixes may be useful when the namespace requires them, but avoid duplicating context already supplied by database and schema ownership.
Microservices, Shards, and Tenant Databases
Each service can use names meaningful within its owned database. There is rarely a need for globally unique identifiers across unrelated databases unless central tooling requires them.
For replicated schemas and shards, deterministic names are essential. The same operational command or catalog check should find the same rule everywhere.
Legacy Database Strategy
Legacy systems often mix generated names, old prefixes, and team-specific abbreviations. Renaming every object creates DDL and deployment risk without necessarily improving behavior.
Apply the standard to new constraints and to modified rules. Rename existing objects when doing so provides a clear maintenance benefit and dependencies have been audited.
Greenfield Database Strategy
Define naming rules before creating many tables. Document prefixes, table ownership, role selection, casing, length fallback, DBMS namespace, and how tools should generate identifiers.
A simple automatable convention followed consistently is stronger than a sophisticated standard that developers cannot apply reliably.
Preventing Naming Collisions
A collision occurs when two constraints receive the same identifier inside a namespace that requires uniqueness. Generic names such as fk_customer are especially vulnerable when many tables reference customers.
Including the child table and relationship role usually resolves the problem: fk_orders_customer and fk_support_cases_customer. Before standardizing a formula, generate names for representative complex tables and verify that each result is distinct.
Column-Based Versus Parent-Based FK Names
Two common patterns are fk_orders_customer_id, which names the child column, and fk_orders_customer, which names the relationship. Both are valid if applied consistently.
Column-based naming is easy to automate, while relationship-based naming is often clearer when several columns form one key. Role-based naming should take priority when a table references the same parent more than once.
Accurate Boundary Language
Words such as positive, nonnegative, future, valid, required, and range imply specific conditions. chk_items_quantity_positive should enforce quantity > 0, while chk_items_quantity_nonnegative should allow zero.
If the expression changes, review the identifier during the same migration. An inaccurate name misleads reviewers and can cause the wrong application error to be shown.
Avoid Encoding Allowed Values
A name such as chk_orders_status_pending_paid_shipped becomes obsolete when a new status is added. Prefer chk_orders_status_valid and let the DDL or referenced lookup table define the exact set.
Names should describe stable intent, while expressions carry details likely to evolve. This balance reduces unnecessary renaming.
Idempotency Constraint Names
Message and API processing often relies on a composite unique constraint such as client plus idempotency key. A name like uq_api_requests_client_idempotency communicates why duplicate input is rejected.
That semantic context is more useful during an incident than a long list of storage columns. It also helps application teams map the violation to a safe retry response.
Catalog Queries and Automated Audits
Database catalogs can be inspected to find generated names, missing prefixes, duplicate conceptual roles, names exceeding an organizational limit, and identifiers that do not include their owning table.
Add naming validation to schema linting or CI when the organization needs strict governance. Allow documented exceptions for vendor-managed objects and legacy constraints rather than forcing unsafe automatic renames.
Testing the Naming Convention
A naming standard should be tested against simple keys, composite keys, self-references, two relationships to one parent, long table names, cross-schema references, and constraints generated by every supported migration tool.
Run fresh creation and upgrade paths. A convention that works only on a clean database but fails against existing generated names is not deployment-ready.
Changing a Constraint Without Changing Meaning
An implementation may change while the invariant remains stable. A CHECK can be replaced with a foreign key to a status table, or a unique constraint may move to a filtered unique index because soft deletes are introduced.
Whether the identifier should remain depends on the DBMS object type and tooling, but the business terminology should stay consistent across migrations, documentation, alerts, and application errors.
Deployment Sequencing for Renames
If application code maps a constraint name to a business response, deploy support for both old and new names before the database rename. Update monitoring and runbooks in the same release window, then remove compatibility after all callers are upgraded.
This expand-and-contract approach prevents a metadata cleanup from breaking production behavior.
Schema Documentation and Runbooks
Document the naming formula, approved abbreviations, casing, namespace assumptions, maximum project length, and fallback for complex constraints. Include examples of good and rejected names.
Operational runbooks should explain how to locate a named constraint, inspect its definition, identify dependent indexes, and change it safely on each supported database engine.
Data Warehouse Constraint Naming
Warehouses may use names such as pk_dim_customer, pk_fact_sales, and fk_fact_sales_customer where dimensional roles are already visible in table names. Do not add redundant tokens merely because the system is analytical.
Some warehouses do not enforce every relationship physically, but documented constraint or test names should still follow a predictable convention.
Staging and Temporary Tables
Staging tables may intentionally permit invalid data so rejected records can be analyzed before promotion. If they do have constraints, use the normal convention or a documented staging variation.
Temporary objects often have narrower lifetime and scope, but names should remain understandable when they appear in execution plans, logs, and troubleshooting sessions.
Audit and History Tables
Audit tables frequently need a primary key, an event sequence, or a relationship to the source entity. Names such as pk_orders_audit and fk_orders_audit_order make ownership obvious.
Do not copy active-table UNIQUE constraints blindly into history tables, because historical versions legitimately repeat business values. Name only rules that match the history table's grain.
Service and Schema Prefixes
A service prefix can be useful when one catalog namespace contains objects from multiple bounded contexts. However, billing_fk_billing_orders_billing_customer repeats information and obscures the meaningful role.
Use the database or schema as the namespace where possible. Add another prefix only when it prevents real ambiguity or satisfies tooling requirements.
Choosing Approved Abbreviations
Standard tokens such as pk, fk, uq, chk, and df are compact and widely understood. Domain abbreviations should be added to a shared glossary before they appear in hundreds of identifiers.
Avoid dropping arbitrary vowels or shortening different words to the same token. Brevity is useful only when maintainers can still predict and interpret the result.
Constraint Naming Decision Flow
- Identify the correct business invariant and constraint type.
- Add the approved type prefix.
- Add the actual owning table name.
- For non-primary rules, add the key, relationship role, or valid outcome.
- Remove details already supplied by schema context.
- Check ambiguity against other constraints on the table.
- Apply approved abbreviations only when required.
- Verify casing, reserved words, namespace, and DBMS length limits.
- Confirm deterministic output from migration and ORM tooling.
- Review whether the name will remain accurate as implementation details evolve.
Worked Multi-Tenant Naming Set
pk_tenants
pk_users
uq_users_tenant_username
uq_users_tenant_email
fk_users_tenant
chk_users_status_valid
pk_projects
uq_projects_tenant_code
fk_projects_tenant
fk_projects_owner
chk_projects_date_range
From the identifiers alone, a reviewer can infer tenant-scoped usernames, emails, and project codes; tenant ownership; project ownership; and the presence of status and date invariants.
Worked Relationship-Role Naming Set
fk_orders_customer
fk_orders_billing_address
fk_orders_shipping_address
fk_orders_created_by_user
fk_orders_approved_by_user
fk_orders_replaced_order
Each name describes how the child uses the parent. Repeating only parent table names would not distinguish these relationships in error messages or catalog output.
Who Owns the Naming Standard?
Database naming should have clear ownership even when many teams contribute migrations. A platform or architecture group can define the baseline, while service teams remain responsible for choosing accurate domain roles and invariants.
Reviews should focus on predictability and meaning rather than personal preference. Exceptions need a short documented reason, an owner, and a rule describing whether similar future cases should follow the exception.
Validating Across Database Engines
A cross-platform organization should test names on every supported engine rather than selecting the most permissive limit. Verify identifier folding, quoted-name behavior, namespace scope, maximum length, default-constraint syntax, and whether constraint metadata is exposed consistently through drivers.
When one portable name is impractical, keep the semantic tokens consistent even if vendor-specific DDL differs. Operational teams should be able to recognize the same rule across platforms.
Naming During Incident Response
During an incident, responders need to move from an application error to the responsible table, rule, recent migration, and owning team quickly. A deterministic identifier makes catalog lookup and code search immediate.
Runbooks can link high-impact constraint names to dashboards and remediation steps. This is especially valuable for idempotency, tenant isolation, settlement totals, inventory, and other invariants whose violations signal broader workflow defects.
Maintaining the Standard Over Time
Review the convention when database platforms, migration frameworks, or organizational boundaries change. Add examples for new patterns such as partitioned uniqueness or temporal constraints without rewriting stable identifiers unnecessarily.
Measure adoption through catalog audits and schema linting. The goal is not perfect cosmetic uniformity; it is reliable understanding, safer changes, and faster diagnosis across the database lifecycle.
Full Order Example
CREATE TABLE orders (
order_id BIGINT NOT NULL,
order_number VARCHAR(30) NOT NULL,
customer_id BIGINT NOT NULL,
status VARCHAR(20)
CONSTRAINT df_orders_status DEFAULT 'PENDING',
total_amount DECIMAL(12,2) NOT NULL,
CONSTRAINT pk_orders PRIMARY KEY (order_id),
CONSTRAINT uq_orders_order_number UNIQUE (order_number),
CONSTRAINT fk_orders_customer
FOREIGN KEY (customer_id)
REFERENCES customers(customer_id),
CONSTRAINT chk_orders_status
CHECK (status IN ('PENDING', 'PAID', 'SHIPPED')),
CONSTRAINT chk_orders_total_nonnegative
CHECK (total_amount >= 0)
);
The schema can be understood quickly because each identifier follows one predictable pattern.
Full Order-Item Example
CREATE TABLE order_items (
order_id BIGINT NOT NULL,
line_number INTEGER NOT NULL,
product_id BIGINT NOT NULL,
quantity INTEGER NOT NULL,
unit_price DECIMAL(12,2) NOT NULL,
CONSTRAINT pk_order_items
PRIMARY KEY (order_id, line_number),
CONSTRAINT fk_order_items_order
FOREIGN KEY (order_id) REFERENCES orders(order_id),
CONSTRAINT fk_order_items_product
FOREIGN KEY (product_id) REFERENCES products(product_id),
CONSTRAINT chk_order_items_quantity_positive
CHECK (quantity > 0),
CONSTRAINT chk_order_items_price_nonnegative
CHECK (unit_price >= 0)
);
Common Naming Mistakes
- Allowing random generated names in persistent production schemas.
- Using identifiers such as
constraint1,key2, orcheck_value. - Omitting the owning table where names become ambiguous.
- Giving two relationships to the same parent indistinguishable names.
- Listing so many columns that names exceed platform limits.
- Using undocumented abbreviations, quoted spaces, or special characters.
- Naming a rule with inaccurate boundaries such as positive when zero is valid.
- Embedding temporary ticket numbers, developers, or business values.
- Depending only on raw error-message text in application logic.
- Renaming constraints without checking monitoring and migration dependencies.
Recommended Naming Standard
| Constraint | Pattern | Example |
|---|---|---|
| Primary key | pk_<table> | pk_orders |
| Foreign key | fk_<child>_<role> | fk_orders_customer |
| Unique | uq_<table>_<key> | uq_users_tenant_username |
| Check | chk_<table>_<rule> | chk_items_quantity_positive |
| Default | df_<table>_<column> | df_orders_status |
| Index | ix_<table>_<purpose> | ix_orders_created_at |
Production Review Checklist
- Confirm that the underlying business rule and constraint type are correct.
- Use the standard type prefix and actual owning table convention.
- Add the relationship role, key, or invariant needed to remove ambiguity.
- Keep the identifier concise, deterministic, and meaningful.
- Use consistent casing and avoid quoting, spaces, and special characters.
- Check reserved words, namespace scope, and identifier length limits.
- Verify that migration and ORM tooling preserves the selected name.
- Confirm error mapping uses structured driver metadata where available.
- Do not expose internal names or sensitive values to public clients.
- Update monitoring, schema documentation, and rollback procedures.
- Check that the name still describes the actual expression and boundary.
- Test fresh installation, upgrade, rollback, and schema-drift comparison.
Interview Questions and Answers
Why name constraints explicitly? Explicit names improve readability, migrations, troubleshooting, schema comparison, logging, and error classification.
Is explicit naming mandatory? Not always. Most databases can generate names, but production schemas benefit from predictable identifiers.
How do you name a primary key? A common pattern is pk_<table>, such as pk_orders.
How do you distinguish two foreign keys to the same table? Include their business roles, such as billing address and shipping address.
Should a constraint name contain every column? Only when that remains readable. A stable business-key name is better for a long combination.
Can applications use constraint names? Yes, alongside SQLSTATE or structured driver metadata, but they should not parse only raw error text.
Constraint name versus index name? They identify different schema concepts: integrity rules and physical access structures.
Why avoid generated names? They can be opaque, environment-dependent, and difficult to use in deterministic migrations.
Key Takeaway
Constraint naming gives database rules predictable operational identities. A strong convention combines the constraint type, owning table, and the business role, key, or invariant needed to explain the rule.
GOOD CONSTRAINT NAME = CONSTRAINT TYPE
+ OWNING TABLE
+ BUSINESS ROLE OR RULE
+ CONSISTENT CONVENTION
+ DBMS-SAFE LENGTH AND SYNTAX
Good naming cannot correct a bad data model. First define the right business invariant and select the right constraint. Then give that constraint a concise, deterministic name that helps developers, migrations, logs, monitoring systems, and future maintainers understand what the database protects.