Manipulation Flashcards

1
Q

What does SQL stand for?

A

Structured Query Language

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

What is SQL?

A

A programming language designed to manipulate data stored in relational databases.

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

SQL operates through _______ statements.

A

declarative

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

What are some advantages of SQL?

A
  • accuracy
  • security
  • integrity
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a Relational Database?

A

A database that organizes information into one or more tables.

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

What is a Table?

A

A collection of data organized into rows and columns.

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

What are Tables referred to as?

A

Relations

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

What is a column in a Table?

A

A set of data values of a particular type.

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

What kind of types would be in a Table column?

A

id TEXT
name TEXT
age INTEGER

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

What is a row in a Table?

A

A single record in a table.

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

T or F: All data stored in a relational database is of a certain data type.

A

True

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

What are some common data types?

A

INTEGER
TEXT
DATE
REAL

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

What type of datatype is INTEGER?

A

A positive or negative whole number

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

What type of datatype is TEXT?

A

A text string

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

What type of datatype is DATE?

A

The date formatted as YYYY-MM-DD

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

What type of datatype is REAL?

A

A decimal value

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

What is a Statement?

A

Text that the database recogonize as a valid command.

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

What do Statements always end in?

A

A semicolon ( ; )

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

CREATE TABLE table_name ( column_1 datatype, column_2 datatype, column_3 datatype ) ;

A

This is an example of a statement.

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

What is CREATE TABLE?

A

A clause.

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

What do Clauses do?

A

Perform specific tasks in SQL.

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

How are Clauses written and why?

A

By convention, clauses are written in capital letters.

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

What are Clauses also referred to as?

A

Commands

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

What does table_name refer to in the CREATE TABLE Statement?

A

The name of the table that the command is applied to.

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

What does column_1 datatype, column_2 datatype, column_3 datatype refer to in the CREATE TABLE Statement?

A

A parameter list of column names and the associated data type.

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

What is a Parameter?

A

A list of columns, data types, or values that are passed to a clause as an argument.

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

T or F: The number of lines used in a SQL statement does not matter.

A

True

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

How can a Statement be written?

A

1) Written all in one line
2) Split up across multiple lines (easier to read)

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

What type of Statement helps us create a new Table?

A

CREATE

30
Q

What type of Statement inserts a new row into a Table?

A

INSERT

31
Q

The INSERT Statement adds what to the Table?

A

Rows

32
Q

What two clauses go with the INSERT Statement?

A

INSERT INTO __ () VALUES()

33
Q

What does the INSERT INTO ___ ( ) clause do?

A

Adds the specified row or rows

34
Q

What does the VALUES clause do?

A

Indicates the data being inserted

35
Q

INSERT INTO celebs (id, name, age) VALUES (1, ‘Justin Bieber’, 22);

A

An INSERT CLAUSE

36
Q

What type of Statement fetches data from the database?

A

SELECT

37
Q

What does a SELECT Statement do?

A

It returns all data in the selected column of the given Table.

38
Q

What does this SELECT statement do?

SELECT name
FROM celebs;

A

It returns all data in the name column

39
Q

Describe what each part of this SELECT statement does

SELECT name
FROM celebs;

A
  1. SELECT is the clause
  2. name is the column to query data from
  3. FROM celebs specifies the name of the table to query data from
40
Q

What is SELECT?

A

A clause that indicates the statement is a query.

41
Q

What type of clause do you use every time you want to query data from a database?

A

SELECT

42
Q

What special wildcard character lets you query data from all columns in a Table with SELECT?

A

*

43
Q

What does this SELECT statement do

SELECT * FROM celebs;

A

This queries all columns in the celebs Table.

44
Q

What is the name for the new Table that is returned from a SELECT statement?

A

The result set

45
Q

What type of Statement adds a new column to the Table?

A

ALTER TABLE

46
Q

What does the clause ALTER TABLE do?

A

Lets you make specified changes.

47
Q

What are the two clauses in the ALTER TABLE statement?

A

ALTER TABLE _____
ADD COLUMN ____ ____ TEXT;

48
Q

What does the clause ADD COLUMN do?

A

Add a new column or table.

49
Q

What must be included in the clause ADD COLUMN?

ADD COLUMN ______ ______;

A

The name of the new column and the data type for the new column.

50
Q

What is NULL? What does it represent?

A

A special value that represents missing or unknown data?

51
Q

What is the symbol for NULL?

A

52
Q

What type of Statement edits a row in a Table?

A

UPDATE

53
Q

What does the clause UPDATE do?

A

Edits a row in the Table.

54
Q

What are the three clauses in the UPDATE statement?

A

UPDATE _______
SET _____________ = ‘ __________ ‘
WHERE ______ = ______;

(UPDATE, SET, and WHERE)

55
Q

Explain what each part in this UPDATE statement does

UPDATE celebs
SET twitter_handle = ‘@taylorswift’
WHERE id = 4;

A

UPDATE is the clause that edits a row in the table
celebs is the name of the table
SET is a clause that indicates the column to edit
twitter_handle is the name of the column that is going to be updated
@taylorswift13 is the new value that is going to be inserted into the twitter_handle column
WHERE is a clause that indicates which rows to update with the new column.
the row with a 4 and the id column is the row that will have the update occur

56
Q

What type of Statement deletes one or more rows from a table

A

DELETE

57
Q

What does the clause DELETE FROM do?

A

Deletes rows from a Table.

58
Q

Explain each part of this DELETE FROM statement?

DELETE FROM celebs
WHERE twitter_handle IS NULL;

A

DELETE FROM is the clause that deletes rows from a table
celebs is the name of the table we want to delete rows from
WHERE is a clause that lets you select which rows to delete. Here all rows with a NULL twitter_handle will be deleted.
IS NULL is a condition that returns true when the value is NULL and false otherwise.

59
Q

What two clauses are in a DELETE FROM statement?

A

DELETE FROM ______
WHERE _______

(DELETE FROM and WHERE)

60
Q

What are Constraints?

A

Add information about how a column can be used or invoked after specifying the data type for a column.

61
Q

How are Constraints used?

A

Used to tell the database to reject inserted data that does not adhere to a certain restriction.

62
Q

What does this Statement do?

CREATE TABLE celebs (
id INTEGER PRIMARY KEY,
name TEXT UNIQUE,
date_of_birth TEXT NOT NULL,
date_of_death TEXT DEFAULT ‘NOT APPLICABLE’
);

A

This statement sets constraints on the celebs table.

63
Q

What are PRIMARY KEY columns?

A

Uniquely identifies the row(s).

64
Q

What would result in a constraint violation? What does it prevent?

A

Attempting to insert a row with an identical value to a row already in the table.

Thus resulting in a constraint violation and not allowing you to insert the new row.

65
Q

What are UNIQUE columns?

A

Different value for every row

66
Q

True or False: A Table can have many different UNIQUE columns.

A

True

67
Q

What are NOT NULL columns?

A

Columns that must have a value.

68
Q

Attempting to insert a row without a value for NOT NULL column will result in a __________ violation. The new ______ will not be inserted.

A

Constraint, row

69
Q

What are DEFAULT columns?

A

Takes an additional argument that will be the assumed value for an inserted row if the new row does not specify a value for that column.

70
Q

A statement is a ______ of _______ that the database recognizes as a valid command.

A

string of characters