1. What is SQL?
SQL is a language used to manage relational databases. It allows storing, retrieving, and updating data. It works with tables and records. It supports queries and data manipulation. It is widely used in applications and analytics. It is essentially a special vocabulary used to ask questions directly to a database. For example, if an online store wants to see all customers who bought shoes today, they use SQL to instantly pull that exact list from their massive tables of data. code SQL SELECT * FROM employees;
SELECT * FROM employees;
2. What is a database?
A database is a collection of organized data. It stores information in structured format. It allows easy access and management. It supports multiple users. It is used in applications to store data. code SQL Employee database
Employee database
3. What is a table?
A table is a structure that stores data in rows and columns. Each row represents a record. Each column represents a field. It is the basic unit of storage. It is used in relational databases. code SQL employees(id, name)
employees(id, name)
4. What is a primary key?
Primary key uniquely identifies each row. It does not allow duplicates. It cannot contain NULL values. It ensures data integrity. It is defined during table creation. code SQL id INT PRIMARY KEY
id INT PRIMARY KEY
5. What is a foreign key?
Foreign key links two tables together. It references primary key of another table. It maintains referential integrity. It ensures valid relationships. It prevents invalid data insertion. code SQL FOREIGN KEY (dept_id) REFERENCES dept(id)
FOREIGN KEY (dept_id) REFERENCES dept(id)