SQL Flashcards
What is a Databse
An organized collection of data stored on a computer.
What does DBMS stand for
Database Management System
What does RDBMS stand for?
Relational Database Management System
What is SQL
SQL stands for Structured Query Language
It is the standard language used for accessing, and storing data from a database
Name some popular Relational Database Management Systems.
- MySQL
- Oracle
- PostgreSQL
- IBM DB2
- MariaDB
What are Tables, Fields, and Records in an SQL Database?
A Table is an organized collection of data defined by the data’s model, that is organized in rows in columns
A field, or a table column, is a label that defines which data should be stored there for each record in the table
A Record, or table row, is a single set of data comprised of all the required fields of the table
List and describe all of the SQL Constraints
NOT NULL: Any value inserted in to this field cannot be NULL
CHECK: Verifies that the values of the affected field satisfy the stated condition
DEFAULT: Assigns a value to a field if no other value was assigned to it.
UNIQUE: For the field marked Unique, every record in the table must have a unique value.
INDEX: indexes a field for faster data retrieval
PRIMARY KEY: A unique field that is used to identify each individual record
FOREIGN KEY: A field that allows the database to link records across different tables.
How does a foreign key work?
When two tables contain related data, a foreign key is used to establish a link between the two tables.
When a relationship is created, the child table will receive a foreign key field and each record that has a relationship to a record on the parent table will have a foreign key that refers to the Primary Key Value of the parent record.
Describe the AS clause
Allows us to define a new name for a field when creating a join.
Describe an Inner Join
Compares all records from two tables and determines if any values of a specified column in table A match any values of a specified column in table B
Returns only the full records from both tables where the specified fields matched
Describe a Full Outer Join
Returns all data from both tables and matches the data records that have matching data in the specified field
Describe an Exclusive Outer Join
Opposite of an inner join
Will only return records where the data in the selected field does not have a match.
Describe an Asymmetrical Join or
Returns all records from table A and only records from table B where the data in the specified fields match
Describe an Exclusive Asymmetrical Join
Selects only the records from Table A that do not have matching data in the specified field in table B
What is the difference between left and right joins?
The only difference in SQL is the order that the tables are referenced.
In a Left Join, table A is referenced first and table B is joined on to table A
In a Right Join, Table B is referenced first and table A is joined on to table B