SQL Fundamentals Flashcards
(17 cards)
What are the 5 database models?
1) Relational (Postgres)
2) Document (MongoDb)
3) Key/Value (Redis)
4) Graph (Neo4j)
5) Wide Columnar (Apache Cassandra)
What is Cardinality?
The number of distinct values in a table column relative to the number of rows in the table. For example, if a column has 100 rows and only 10 unique values, the cardinality of that column is 10.
What is a primary key?
It is a unique identifier for each row in a table
What is a foreign key?
It is a key that references the primary key in another table
What is OLTP?
Online transaction processes.
What is OLAP?
Online Analytical Processing
What are the 2 DCL (Data Control Language) commands?
1) Grant
2) Revoke
What are the 6 DDL (Data Definition Language) commands?
1) Create
2) Alter
3) Drop
4) Rename
5) Truncate
6) Comment
What is the 1 DQL (Data Q Language) command?
Select
What are the 7 DML (Data Modification Language) commands?
1) Insert
2) Update
3) Delete
4) Merge
5) Call
6) Explain Plain
7) Lock Table
How do you rename a column in SQL?
SELECT column as <new_name></new_name>
What is the diff between single & double quotes in SQL?
Single: Refers to characters/text
Double: Refers to column name
How do you combine 2 columns in a query?
SELECT CONCAT(col1, ‘ ‘, col2) AS <new> from tableName</new>
What is an Aggregate function in SQL?
It is a function that aggregates data. Example is SUM, that returns the sum of all items.
What is a Scalar function in SQL?
It is a function that runs for each row in the dataset. Example is CONCAT
What is the order of Precedence in a SQL query?
1) Parenthesis
2) Multiplication/Division
3) Subtraction/Addition
4) NOT
5) AND
6) OR