📊

Essential Topics in SQL Course

May 28, 2025

SQL Course Lecture Notes

Introduction

  • Trainer: Amit Diwan
  • Focus: Microsoft SQL Server for beginners
  • Tools: Microsoft SQL Server Express Edition (free and open-source)
  • Includes: Over 100 live running examples

Key Concepts

What is RDBMS?

  • RDBMS: Relational Database Management System
  • Stores data in table format (rows and columns)
  • Basis for SQL and others like MySQL, Oracle

SQL Overview

  • SQL: Structured Query Language
  • Stores data in RDBMS format
  • Governed by ANSI and ISO
  • Used for creating and maintaining databases
  • Tool: SQL Server Management Studio (SSMS)

Differences: SQL vs NoSQL

  • SQL: Follows relational model (tables with rows and columns)
  • NoSQL: Supports diverse data models (document, key-value, graph)
  • SQL databases: MySQL, Oracle, Microsoft SQL Server
  • NoSQL database example: MongoDB

SQL Basics

SQL Basics and Features

  • SQL uses tables with rows and columns to store data
  • Tables are collections of related data entries

Installing SQL Server

  • Step-by-step installation guide for SQL Server 2022 (Express Edition)
  • Importance of SSMS for database operations

Basic Operations

  • Creating Database: Using CREATE DATABASE command
  • Creating Table: Using CREATE TABLE with column definitions
  • Inserting Records: Using INSERT INTO command
  • Selecting Data: Using SELECT statement with optional WHERE clause

Advanced Operations

  • Ordering Data: Using ORDER BY, ASC, and DESC
  • Using Operators: AND, OR, NOT, IN, BETWEEN
  • Aggregate Functions: MAX, MIN, SUM, AVG, COUNT

SQL Constraints

Constraints Overview

  • Not Null: Ensures column does not accept NULL values
  • Unique: Ensures all values in a column are different
  • Primary Key: Uniquely identifies each record
  • Foreign Key: References a primary key in another table
  • Check: Ensures values fulfill a specified condition

SQL Advanced Features

Modifying and Updating

  • Alter Table: Adding or deleting columns
  • Update Records: Modifying existing records
  • Alias: Temporary name for table or column

Stored Procedures

  • Predefined SQL code block for repetitive tasks
  • Can include parameters for dynamic operations

Indexes

  • Improve speed of data retrieval via indexing
  • Created using CREATE INDEX

Backup and Views

  • Backup Database: BACKUP DATABASE command
  • Views: Virtual tables created using CREATE VIEW

Drop and Delete

Dropping Elements

  • Drop Table: DROP TABLE deletes a table and its records
  • Drop View: DROP VIEW deletes a view

This document summarizes the key points from the SQL course lecture. Use it to review and study the fundamental SQL concepts and operations.