One Pager Cheat Sheet
- A database is
a systemused tosave and process datain an efficient manner, usuallystored in a tabularformat toinsertand manipulate information. SQLis a global standardstructured query language, which is used to perform operations onrelational databaseslike inserting, deleting, and updating, and is considered intuitive and easy-to-use.- The
SQLstatementCREATE TABLEis used to create a new table in a database, specifying a mandatory table_name and the optional columns with their datatypes. - Using the
CREATE TABLEstatement, we can create a new table or derive one from an existing table in an existing database. - We can
createa new table calledClasscontaining "studies" information by passingcolumn namesand their correspondingdata typesto a query. - SQL
DESCandDESCRIBEare alias statements used to list information about a table, such as key attributes and data types. DESCRIBEis a helpfulSQLstatement for seeing information about a table, such as column names, data types and null value presence.- The SELECT statement is used to query a table for specific data, returning a
result-setof its associated columns and properties. - The
SELECTstatement in SQL is an intuitive way toretrieve columnsfrom agiven table. - The statement
SELECT *will extractall columnsfrom a table. INSERT,UPDATE, andDELETEare SQL statements used to manipulate values stored in atable.- To update or delete records from a table in a database, you can use
UPDATEorDELETESQL statements respectively. - The BETWEEN operator is used with the
WHEREclause to select values within a specified range and is not valid without it. - We can use the
BETWEENoperator to perform an operation on a specified range, by combining it with theSELECT/ FROMandWHEREstatements. - The order of operations in the WHERE clause is determined by the order of precedence which consists of relational operators (
>=,>,<=,<) followed by the OR operator, and finally the equality checks (=and!=). - The order of operations within the
WHEREclause can be enforced with parentheses (()) to selectively filter data using theSELECT/ FROMstatement. - You can
find studentswhose attendance count is greater than 80 in English by using logical operators. - The
WHEREclause works on individual records, while theHAVINGclause works ongrouped dataand allows us to useaggregate functions. - We
groupthe data and then use theHAVINGclause to apply the condition. - Aggregate functions, such as
AVG(), return a single value calculated from a set of input values. Aggregate functionsare used to compute and return a single value from multiple values in aSQLdatabase, such asMIN(),MAX(),SUM(),AVG(), andCOUNT().- The
MIN()function is used tofind the row with the minimum valueof acolumnin a query. - The
MAX()functionis usedto find the maximum value of a column. - The
SUM()function can be used to find the total amount of values from a column. - The
AVG()function is used to calculate the mean value of a column. - The
COUNT()function is used to find the number of rows for a given column, not ignoringnullvalues by default. - The
JOINclause is used tojoindata from multiple tables based on their common columns, forming relationships and returning a single result set. - The JOIN clause is used in
SQLto combine two or more tables based on a mutual column, and can be executed with four types of joins:INNER,RIGHT OUTER,LEFT OUTER, andFULL OUTER.


