Quick Recap of SQL Concepts
1. What is SQL?
SQL (Structured Query Language) is a standard programming language used for managing and manipulating relational databases.
2. What are the different types of SQL commands?
- Data Definition Language (DDL): Used to define the structure of database objects (CREATE, ALTER, DROP).
- Data Manipulation Language (DML): Used to manipulate data in the database (SELECT, INSERT, UPDATE, DELETE).
- Data Control Language (DCL): Used to control access and permissions on database objects (GRANT, REVOKE).
3. What is a database schema?
A database schema is a logical structure that represents the layout of the database, including tables, columns, relationships, constraints, and indexes.
4. What is a primary key?
A primary key is a unique identifier for each record in a table. It ensures that each row in the table is uniquely identified and helps maintain data integrity.
5. What is a foreign key?
A foreign key is a column or set of columns in one table that references the primary key in another table. It establishes a relationship between the two tables.
6. What is normalization in SQL?
Normalization is the process of organizing data in a database to reduce redundancy and dependency by dividing large tables into smaller tables and defining relationships between them.
7. What is an index in SQL?
An index is a data structure that improves the speed of data retrieval operations on a database table. It allows for faster searching and sorting of data based on specific columns.
8. What is a JOIN in SQL?
A JOIN is used to combine rows from two or more tables based on a related column between them. Common types of JOINs include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
9. What is a subquery in SQL?
A subquery is a query nested within another query. It allows you to perform complex queries by using the result of one query as input for another query.
10. What is the difference between SQL and NoSQL databases?
- SQL databases are relational databases that store data in structured tables with predefined schemas, while NoSQL databases are non-relational databases that store data in flexible, schema-less formats.
- SQL databases use SQL for querying and manipulating data, while NoSQL databases use various query languages or APIs.
- SQL databases are suitable for complex queries and transactions, while NoSQL databases are better for handling large volumes of unstructured data and scaling horizontally.