One Pager Cheat Sheet
- Review the
best SQL Interview Practice Questionssourced from interviews with top tech companies like Google, Oracle, Amazon, and Microsoft to help you ace the interview. - SQL is a standard language for accessing and manipulating structured databases, such as MySQL, where queries can be used to perform select or action operations and sub-queries can be used to retrieve specific data.
- A nested query or
sub-queryis used to return data from a database, which is then used by the main query as a condition. - A Database Management System (DBMS) is a software used to define, create, and maintain a database, while a Relational Database Management System (RDBMS) is an advanced version of a DBMS which stores data in the form of tables and maintains data integrity by enforcing a set of rules and standards.
- All values in a field must be
uniqueand enforced through aunique indexto ensure data stored is consistent and accurate. - A
Primary Keyis a constraint that uniquely identifies each row in a table and can be comprised of single or multiple fields, while aForeign Keyrefers to aPrimary Keyin another table to ensure referential integrity. - A
Primary Keymust contain unique values and not allownullvalues. - A
JOINclause is used to combine rows from two or more tables, with the typesINNER JOIN,LEFT JOIN,RIGHT JOINandFULL JOIN, while aSELF JOINlinks a table to itself and aCROSS JOINis a Cartesian product of the two tables included in the join. - An
INNER JOINonly returns records that have a match in both tables, whereas other types of joins return all records from one of the tables regardless of whether there is a match in the other. - You can use
SELECT,WHERE,ORDER BY,GROUP BY,HAVING,UNION,MINUS,INTERSECT,TRUNCATE,DELETE,DROP,CREATE VIEW,ALTER TABLEandLIKEcommands to query, change and manipulate data in SQL. - The
SELECT DISTINCTcommand eliminates duplicate rows from a result set, providing only a distinct set of data different from the plainSELECTcommand. - SQL has three major types of relationships: one-to-one, many-to-one, and many-to-many, which all involve linking or associating records of one table to another.
- A one-to-one relationship exists between a person and their passport, as each passport can only belong to one person and vice versa.
- Normalization is a way of structuring data efficiently, while Denormalization is the opposite process that adds redundancy to improve performance, both of which are illustrated via 1NF, 2NF, 3NF, and 4NF.
- Denormalization increases data redundancy to improve query performance, reducing the overhead of
joinsandrelationshipsbetween tables. - Indexing is used to improve the speed of data retrieval from a database table, at the cost of additional time for updates, with
clusteredandnon-clusteredindexing offering different advantages. - No table can have more than one
Clustered Index, as it would require the data to bephysically stored in multiple orders, which is not possible. - OLTP
processesdata fromtransactionsinreal timefor day-to-day operations, whereas OLAPanalyzesaggregated data from OLTP databases and other sources for business decision-making. - OLAP is used to analyze and aggregate data from a data warehouse or other sources for business intelligence and analytics, while OLTP focuses on transaction-oriented applications such as processing orders.
- PostgreSQL is an
enterprise-level DBMSthat supports a variety ofdata typessuch asUUID,Numeric types,Temporal types, andJSON, and also provides features such asTable PartitioningandString Constantsto help developers build enterprise-level applications. - PostgreSQL is a continuation of the
POSTGRESproject, based on INGRES and developed at the University of California at Berkeley to support relational databases on UNIX-like systems.


