A Simple Use Case for Indexes on Primary Keys

Introduction

Recently we encountered an interesting performance problem on one of our SQL Server databases that process transactions at a serious rate. The transaction table used to capture these transactions became a hot table. As a result, the problem showed up in the application layer. It was an intermittent timeout of the session seeking to post transactions.

This happened because a session would typically “hold on” to the table and cause a series of spurious locks in the database.

CodingSight - A Simple Use Case for Indexes on Primary Keys
Read More

How to Create a Table with Multiple Foreign Keys and Not Get Confused

Understanding Table Relations

SQL server adds foreign keys to implement relations between tables in a relational database. A table can have one-to-one, one-to-many, or many-to-many relations with another table, depending upon the type of data you want to store.

A one-to-one relationship is simple and rarely used. Each record in a particular table relates to exactly one record in another table.

CodingSight - How to Create a Table with Multiple Foreign Keys and Not Get Confused
Read More