nvarchar(max) vs nvarchar(N)
MS SQL Server offers several data types for storing strings.
The most popular are nvarchar(N) (1 ≤ N ≤ 4000) and nvarchar(max), which allow storing Unicode-encoded string data.
Application developers often transfer their experience with the string type from programming languages like C# or Java to databases and automatically choose nvarchar(max), which can store strings up to 2GB.
However, databases store and process data in fundamentally different ways.
In this article, I will explain and demonstrate the consequences of unjustified use of the nvarchar(max) type.
Patterns: Specification
Specification pattern unites Domain-Driven Design, application architecture modeling and Entity Framework in C#. Specification pattern is designed to order business rules and connect our code to the business terms. This article shows an example of the implementation with Entity Framework.
Useful Constraints
Usually we use constraints to specify the allowable values for the columns in tables. And it works perfectly! But beyond that, constraints help query analyzer to generate more effective query plans. How does it work? Read below.