Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Exposing Ids: int Identity, GUID v7 and the Public Id Split
The most balanced way to expose an id is a bigint identity as the internal clustered key, an immutable unique PublicId outside, and an ownership condition in every query. In our measurement Guid.CreateVersion7 fragmented as badly as v4 in SQL Server (99 percent, 4,987 pages), because SQL Server sorts uniqueidentifier by its last 6 bytes; EF Core's sequential generator stayed close to identity.
Sentinel Values: The Hidden Cost of 0, -1, "1900-01-01" and 9999-12-31
Sentinel values (0 in salary, 9999-12-31 in an end date, 1900-01-01 in a date) silently corrupt aggregates: in the example the average salary comes out as 51,000 instead of 85,000. The fix is usually a nullable column, a separate state field when absence has several meanings and a Special Case type in the domain; a sentinel can be a deliberate standard only when a single producer owns it (temporal tables, a persisted computed column).
The Shadow Record: A Virtual Root That Doesn't Exist in the Database — "Company = 0" Above Departments
A "Company = 0" root that doesn't exist in the database works safely if 0 is turned into a DepartmentScope type (null inside) right at the API boundary; carry 0 as a plain int and you get empty lists on reads and FK violations on writes. The post compares the virtual root, a real root row, a Company entity and an explicit scope contract with their trade-offs.
What Is a Solution Pattern? Real-World Problems Missing from GoF and the Pattern Template
A solution pattern is a recurring application decision that, unlike the code-structure patterns of GoF (the Gang of Four), cuts across data, API and UI together (soft delete, sentinel values, a virtual root). This post introduces the series' Pattern Template, its fixed trade-off criteria and the schema of the HR Portal sample application.