Week 3 Flashcards
SQL Sublanguages (5)
- DDL - data definition language
- DML - data manipulation language
- DQL - data query language
- DCL - data control language
- TCL - transaction control language
Define DDL
- data definition language - statements used to create tables and databases as well as defined properties
- create, alter, drop, truncate
Define DML
- data manipulation language - statements used to insert or remove data from tables
- insert, update, delete
Define DQL
- data query language - statements used to query data from a table
- select
Define DCL
- data control language - statements used to control who can access data
- grant, revoke
Define TCL
- transaction control language - statements used to commit and restore data through transaction. Transactions group a set of tasks into a single execution unit.
- commit, rollback, savepoint
Numeric SQL Datatypes (7)
- INT
- TINYINT
- BIGINT
- DECIMAL
- NUMERIC
- FLOAT
- REAL
Date/Time SQL Datatypes (5)
- DATE
- TIMESTAMP
- DATETIME
- TIME
- YEAR
Character/String SQL Datatypes (5)
- CHAR
- NCHAR
- VARCHAR
- NVARCHAR
- NTEXT
Binary SQL Datatypes (3)
- BINARY
- VARBINARY
- IMAGE
Miscellaneous SQL Datatypes (4)
- CLOB
- BLOB
- XML
- JSON
“Industry etiquette” for writing SQL
- use UPPERCASE to refer to keywords, and lowercase for non-SQL specific entities (like tables or column names)
Define database schema
- Refers to the structure of the database - the columns of each table, their data types, and any constraints on them
Define constraints and list (7)
- allow us to enforce the schema by ensuring consistency and integrity of the data in the table
1. PRIMARY KEY
2. FOREIGN KEY
3. NOT NULL
4. UNIQUE
5. CHECK
6. DEFAULT
7. AUTO INCREMENT
Explain PRIMARY KEY constraint
- uniquely identifies a record in a table
- inherently composed of two other constraints - unique and not null
What are the properties a transaction must follow (4)?
ACID
- Atomicity - all or nothing (transaction must fully complete or rollback)
- Consistency - data remains in a consistent state after the transaction
- Isolation - transactions do not interfere with one another when running
- Durability - data will persist even in case of catastrophic failure
Explain the different isolation levels (4).
What read phenomena do each prevent?
- Serializable - slowest, prevents phantom reads
- Repeatable Reads - prevents non-repeatable reads, allows phantom reads
- Read Committed - prevents dirty reads, allows non-repeatable reads
- Read Uncommitted - fastest, allows dirty reads
What is RDBMS?
- relation database management system
- A database is a collection of data, and the management system is a set of programs to store and access that data in a quick and effective manner
- Developed to handle large amounts of data
What vendors are supported by RDS?
- MySQL
- Oracle
- SQLServer
- Postgres
- Amazon Aurora
- MariaDB
Relational vs non-relational databases
- non-relational does no store data within tables that relate to each other, thus does not use SQL to interact with the database
Explain FOREIGN KEY constraint
- signifies that a column represents a reference to the primary key of another table. This allows us to create relationships between tables
Explain NOT NULL constraint
- enforces that all records must have a field for the column on which this constraint is applied
Explain UNIQUE constraint
- records cannot be inserted if another record already has the same value for the column on which this is declared (similar to NOT NULL)
Explain CHECK constraint
- provides a way of performing validation on values before records are entered into the table