Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Modeling Relationships: One-to-One, One-to-Many, Many-to-Many, Self-Reference and Weak Entities
Relationships land in tables through rules derived from the model: the 1-N foreign key sits on the many side, M-N is an associative entity with its own identity, and a 1-1 foreign key sits on the optional side as the primary key. In SQL Server we show a link table whose key changes when a role is added, the cycle trap in self-references, a ternary relationship that breaks when split, ON DELETE CASCADE derived from a weak entity, and the two meanings of a nullable foreign key.
Relationships in EF Core, Part 2: One-to-One, Many-to-Many and UsingEntity
We build one-to-one with Author and AuthorProfile and many-to-many with Book and Tag: the unique foreign key index, the dependent-side error and HasForeignKey<T>, skip navigations and the BookTag table created by convention, naming the join table with UsingEntity and a join entity with a TaggedAt payload.