liveBook · Manning

Schema

As explained in 100 SQL Server Mistakes and How to Avoid Them

A schema is a named namespace in a database that contains and organizes securable objects.

A database schema organizes entities, attributes, and their relationships into a data model. Treating schema design as personal judgment may seem practical, but different experience levels produce inconsistent structures, duplication, and performance problems. section 4.1

Avoid these common schema-design mistakes:

  • Mistake 1—assuming a sensible-looking design is normalized. Use an Entity Relationship Diagram (ERD) to identify entities, attributes, and relationships before implementation. section 4.1
  • Mistake 2—storing compound values in one attribute. A customer name such as Peter A. Carter should use separate first-name, middle-initial, and last-name values when those parts retain meaning independently. section 4.1.2
  • Mistake 3—repeating category data for every subcategory. Duplication wastes space, increases table size and memory use, reduces index efficiency, and makes inserts and updates less efficient. section 4.1.2
  • Mistake 4—letting incremental development replace architecture. Design sprints can review each database schema before accumulated changes create a tangled, duplicated structure. section 2.2

The MagicChoc naming trap

Ambiguous names such as @Address, @date, and @Product obscure whether values represent billing addresses, delivery addresses, order dates, products, or quantities. Replacing them with @BillingAddressID, @DeliveryAddressID, @OrderDate, @ProductID, and @OrderQty clarifies the schema and keeps meaning consistent through procedures, tables, XML, and downstream calls. section 2.2

SELECT SUBSTRING(CustomerName, 0, CHARINDEX(' ', CustomerName, 1))
FROM Customers ;

Inspecting a query that extracts a first name from CustomerName makes the cost of non-atomic schema values immediately visible. section 4.1.2

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Explains ERDs, atomic values, duplication, normalization, and naming consequences, but does not detail complete normalization procedures.
Examples
Uses customer names, product categories and subcategories, ERDs, T-SQL name extraction, and MagicChoc stored procedures.
What you can do after
Builds and evaluates schemas with ERDs, atomic values, normalization rules, and descriptive object names.
How it connects
Connects schemas with entity relationship diagrams, data modeling, normalization, denormalization, data duplication, and object naming.

Also explained in

Compare how 44 books explain schema →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.