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
Explain DEFAULT constraint
- allows setting default values on columns for records that are inserted into the table
Explain AUTO INCREMENT constraint
- allows a unique number to be generated automatically when a new record is inserted into a table
What is a candidate key?
What is a composite key?
What is a surrogate key?
candidate - multiple columns that together create a primary key to uniquely identify rows
composite - the actual combination of columns to use as the primary keys
surrogate - a column that can uniquely identify a record (can act as Primary Key)
Multiplicity relationship: one to one
- each entity in a table only relates to a single entity in another table
- to enforce the one to one aspect, use a foreign key to relate to the primary key on another table; putUNIQUE constraint on the foreign key column
Multiplicity relationship: one to many / many to one
- one entity can belong to, own, or otherwise relate to multiple other entities
- to create this in the database, we add the foreign key only on the many side of the relationship
Multiplicity relationship: many to many
- implies a one-to-many relationship in both directions on the entities
- we cannot provide a direct link between the tables in the database - instead, use a 3rd table, called a junction table, to connect them. the junctiontable will have 2 foreign keys and will be the many side of both relations
what are junction tables?
- direct link between tables in a many to many relationship
- also known as bridge table
what is normalization? normal forms (3)?
- The process of reducing redundancy in a database
1. 1NF
2. 2NF
3. 3NF
“swearing to tell the truth, the whole truth, and nothing but the truth”
How would you describe AWS? What is “the cloud” or “cloud computing” and why is it so popular now?
- AWS is leading cloud platform
- Provides resources and services
- Business benefits: no need to manage infrastructure; useful tooling; worldwide distribution/deployment
- Downsides: locked into cloud provider
Define Infrastructure, Platform, and Software as a Service
- IaaS: direct access to hardware; most control
- PaaS: hardware abstracted; developer provides the software to run
- SaaS: software abstracted
What’s the difference between a Region and an Availability Zone (AZ)?
Regions cover a geographic area, all over the world
AZs are individual data centers; 3 AZs per region for redundancy and fault tolerance
How are you charged for using AWS services? Does it vary by service?
By uptime, data stored, data exchanged
Different ways to interact with AWS services?
- Web console
- AWS CLI / REST API
- AWS SDK (software development kit)
What is RDS?
relational database service - a PaaS offering that loads RDBMS software based on your configuration
Explain the AWS service - Route 53
- DNS (domain name service) for registering domain names like ‘.com’ or ‘.net’ addresses
- Works to resolve ‘somesite.come’ into an IP address where your server is located
Explain the AWS service - VPN
- Virtual Private Network - can place your cloud resources in a VPN for network security purposes