Mark As Completed Discussion

One Pager Cheat Sheet

  • Review the best SQL Interview Practice Questions sourced 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-query is 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 unique and enforced through a unique index to ensure data stored is consistent and accurate.
  • A Primary Key is a constraint that uniquely identifies each row in a table and can be comprised of single or multiple fields, while a Foreign Key refers to a Primary Key in another table to ensure referential integrity.
  • A Primary Key must contain unique values and not allow null values.
  • A JOIN clause is used to combine rows from two or more tables, with the types INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN, while a SELF JOIN links a table to itself and a CROSS JOIN is a Cartesian product of the two tables included in the join.
  • An INNER JOIN only 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 TABLE and LIKE commands to query, change and manipulate data in SQL.
  • The SELECT DISTINCT command eliminates duplicate rows from a result set, providing only a distinct set of data different from the plain SELECT command.
  • 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 joins and relationships between tables.
  • Indexing is used to improve the speed of data retrieval from a database table, at the cost of additional time for updates, with clustered and non-clustered indexing offering different advantages.
  • No table can have more than one Clustered Index, as it would require the data to be physically stored in multiple orders, which is not possible.
  • OLTP processes data from transactions in real time for day-to-day operations, whereas OLAP analyzes aggregated 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 DBMS that supports a variety of data types such as UUID, Numeric types, Temporal types, and JSON, and also provides features such as Table Partitioning and String Constants to help developers build enterprise-level applications.
  • PostgreSQL is a continuation of the POSTGRES project, based on INGRES and developed at the University of California at Berkeley to support relational databases on UNIX-like systems.