SQL (Structured Query Language) is a standard programming language specifically designed for managing and manipulating relational databases. Understanding SQL fundamentals is crucial for anyone working with databases. Here are some of the key concepts and commands you need to be familiar with:
Basic Concepts:
Database: A structured collection of data.
Table: A collection of related data entries consisting of rows and columns.
Row (Record): A single entry in a table.
Column (Field): A specific attribute of a table.
Primary Key: A unique identifier for a row in a table.
Foreign Key: A field in one table that uniquely identifies a row of another table.
Common SQL Statements:
Data Definition Language (DDL): Used to define the structure of the database.
CREATE: To create a new table or database.
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
HireDate DATE
);
ALTER: To modify an existing table.
ALTER TABLE Employees ADD COLUMN Department VARCHAR(50);
DROP: To delete a table or database.
DROP TABLE Employees;
Data Manipulation Language (DML): Used to manipulate the data within tables.
SELECT: To query data from the database.
SELECT FirstName, LastName FROM Employees WHERE Department = 'Engineering';