Home
Babin Joshi
Cancel

Loops

Using Variables in T-SQL Variables are needed to set values DECLARE @variablename data_type Must start with the character @ Vari...

Counts and Totals

Examining Totals with Counts SELECT COUNT(*) FROM Incidents The above sql statments returns the total number of rows in the Incidents table. Count w...

Intermediate To SQL Server

Exploring Data With Aggregation Reviewing summarized values for each column is a common first step in analyzing data If the data exists in a database, fastest way to aggreg...

Model 1:N relationships with foreign keys

Implementing relationships with Foreign Keys A Foreign Key (FK) points to the Primary key (PK) of another table. Domain of FK must be equal to the domain of PK Each v...

Keys and Superkeys

What is a Key? Attribute(s) that idenfity a record uniquely As long as attributes can be removed: superkey If no more attributes can be removed: minimal superky or ke...

Constraints

Integrity Constraints Attribute Constraints, e.g data types on columns Key Constraints, e.g primary keys Referential Integrity Constraints, enforced through foreign k...

Relational Databases

Using information schema SELECT table_schema, table_name FROM information_schema.tables; Taking the look at the columns of a ...

CRUD Operations

CRUD OPERATION CREATE Databases, Tables or Views Users, prermissions and security groups READ Example: SELEC...

Joining Tables

PRIMARY KEYS: A primary key is used to ensure data in the specific column is unique. It is a column cannot have NULL values. It is either an existing table column or a column that is speci...

Aggregating Data

SUM It is used to calculate the total amount of a column. Example: SELECT SUM(affected_customers) AS total_affec...