Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Constraints and Schema Changes: PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, DEFAULT and ALTER TABLE
Constraints are rules enforced no matter which path writes the data; in SQL Server a UNIQUE column accepts a single NULL, SQL:2023's NULLS NOT DISTINCT option is missing, and the fix is a filtered unique index. We show named constraints, IDENTITY versus SEQUENCE, ON DELETE CASCADE versus NO ACTION, CHECK letting NULL through, safe schema changes with ALTER TABLE, and how WITH NOCHECK leaves a constraint untrusted and costs the query plan.
Relationships in EF Core, Part 1: One-to-Many, Foreign Keys and Cascade Delete
We build a one-to-many relationship with Author and Book: principal, dependent and foreign key, how the convention finds the relationship, HasOne/WithMany in the Fluent API, adding graphs and fixup, required versus optional relationships, and real SQLite output for Cascade, ClientSetNull and Restrict with loaded and unloaded dependents.