Fundamentals of SQL Flashcards

1
Q

SQL

A

Structured Query Language. Special purpose programming language. Built to manipulate relational databases. Declarative language.Contains both a data definition syntax as well as a data manipulation syntax.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Database

A

Container that helps us organize data in a way that makes the data useful or constructive. Useful when you have some threshold amount of data. 500 excel spreadsheets instead of 5. Putting all of the data in one place makes it easy to query data, update data, insert new data, and delete old data. One source of truth rather than many sources of truth. Many types: relational, object-oriented, document-based.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Relational

A

Data and relationship between data entities. The pure Relational Model is math all the way down. Based on relational algebra and tuple relational calculus.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Table

A

In a relational database, data is stored in a construct known as a Table. Name, and a collection of Columns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Column

A

Has a name. Has a restriction that restricts the size and category of data that can be stored in that Column.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Required Columns

A

row contains data. Data not required is referred as null.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Rows

A

Rows can be retrieved by asking questions of the data. Put data in a database to get it out and find answers to questions. Questions will related to values stored in those columns. “Who are all my contacts that have a phone number that starts with 310?” Asking such questions with SQL is known as querying.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Keys

A

Belong to tables. Each table should/must have one column that uniquely identify a row. This column is known as the Primary Key. If more than one table uses the same primary key, you can then merge those two tables together.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Foreign Key

A

Table can also have a column that is classified as foreign. This key links that table to another Table’s Primary Key. Allows rows from each table to be linked together.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Natural Keys

A

Like an ISBN number for a book - unique across all published books on the planet.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Invented Keys

A

Usually an integer is sufficient. Often a database will add this data in each row automatically for you - often called an identity column.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Normalization

A

The design process in database design.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

SQL Statement

A

A valid SQL statement is made up of an actionable set of valid words. Some of the words are defined by SQL, some are defined by you. SQL is english-based so it is readable. Not case-sensitive.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Clause

A

Most parts of a SQL statement can be broken down into clauses. SQL component parts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Valid SQL Statement

A

A valid SQL statement has a semi-colon(;) at the end of the statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Comments

A

Comments are good for documentation of SQL statements saved for re-use. – is for single-line comments. /* is for multi-line comments*/

17
Q

Command

A

SQL statements all start with a command. Generally the command is a verb.

18
Q

Select

A

tells the system we would like to select a piece of data. It is supposed to give us something. i.e “SELECT VALUES From TableName ; “

19
Q

Naming things

A

important for being able to use a database successfully.

20
Q

Table Names

A

Should be singular. a table name describes what a row of data in that table “is” (e.g. user,email, phone).

21
Q

Column Names

A

Will never be repeated inside of a particular database. This is to keep things clear when looking at names of columns.

22
Q

Scoped Names

A

Names in SQL are scoped. A database will have a name. Tables inside of a database will have a name, but a Table name should be referred to using its “full” name, which includes the Database name. A Period is used to separate each part of the name. i.e.”Database.Table”. Columns are also scoped: “Table.Column”

23
Q

Character Data

A

Can hold N character values - Set to N statically.

24
Q

Character Varying Data

A

Can hold N character values - Set to N dynamically - Storage can be less than N.

25
Q

Binary Data

A

Hexadecimal Data

26
Q

SMALLINT

A

-2^15(-32,768 to 2^15-1 (32,767)

27
Q

Integer

A

-2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647)

28
Q

BIGINT

A

-2^63 (-9,223,372,036,854,775,808 to 2^63-1 (9,223,372,036,854,775,807)

29
Q

BOOLEAN

A

TRUE or FALSE

30
Q

DATE

A

YEAR, MONTH, and DAY in the format YYYY-MM-DD

31
Q

TIME

A

HOUR,MINUTE, and SECOND in the format HH:MM:SS[.sF] where F is the fractional part of the second value.

32
Q

TIMESTAMP

A

Both DATE and TIME

33
Q

RDMS

A

Relational Database Management System. More than just a Database. Also includes tools and application to help manage larger-scale database installations.

34
Q

ANSI SQL

A

Most relational database management systems extend ANSI with vendor-specific extensions. Most are proprietary:

  • Oracle has PL/SQL
  • SQL Server has T-SQL

Most ANSI SQL will work with any RDMS.

35
Q

MYSQL

A

Free and open-source. Runs on all major platforms:Windows, OSX, Linux. Has an ANSI operation mode that enforces ANSI compliance (Most RDMS do not have this feature.)