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
What does column_1 datatype, column_2 datatype, column_3 datatype refer to in the CREATE TABLE Statement?
A parameter list of column names and the associated data type.
26
What is a Parameter?
A list of columns, data types, or values that are passed to a clause as an argument.
27
T or F: The number of lines used in a SQL statement does not matter.
True
28
How can a Statement be written?
1) Written all in one line 2) Split up across multiple lines (easier to read)
29
What type of Statement helps us create a new Table?
CREATE
30
What type of Statement inserts a new row into a Table?
INSERT
31
The INSERT Statement adds what to the Table?
Rows
32
What two clauses go with the INSERT Statement?
INSERT INTO __ () VALUES()
33
What does the INSERT INTO ___ ( ) clause do?
Adds the specified row or rows
34
What does the VALUES clause do?
Indicates the data being inserted
35
INSERT INTO celebs (id, name, age) VALUES (1, 'Justin Bieber', 22);
An INSERT CLAUSE
36
What type of Statement fetches data from the database?
SELECT
37
What does a SELECT Statement do?
It returns all data in the selected column of the given Table.
38
What does this SELECT statement do? SELECT name FROM celebs;
It returns all data in the name column
39
Describe what each part of this SELECT statement does SELECT name FROM celebs;
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
What is SELECT?
A clause that indicates the statement is a query.
41
What type of clause do you use every time you want to query data from a database?
SELECT
42
What special wildcard character lets you query data from all columns in a Table with SELECT?
*
43
What does this SELECT statement do SELECT * FROM celebs;
This queries all columns in the celebs Table.
44
What is the name for the new Table that is returned from a SELECT statement?
The result set
45
What type of Statement adds a new column to the Table?
ALTER TABLE
46
What does the clause ALTER TABLE do?
Lets you make specified changes.
47
What are the two clauses in the ALTER TABLE statement?
ALTER TABLE _____ ADD COLUMN ____ ____ TEXT;
48
What does the clause ADD COLUMN do?
Add a new column or table.
49
What must be included in the clause ADD COLUMN? ADD COLUMN ______ ______;
The name of the new column and the data type for the new column.
50
What is NULL? What does it represent?
A special value that represents missing or unknown data?
51
What is the symbol for NULL?
52
What type of Statement edits a row in a Table?
UPDATE
53
What does the clause UPDATE do?
Edits a row in the Table.
54
What are the three clauses in the UPDATE statement?
UPDATE _______ SET _____________ = ' __________ ' WHERE ______ = ______; (UPDATE, SET, and WHERE)
55
Explain what each part in this UPDATE statement does UPDATE celebs SET twitter_handle = '@taylorswift' WHERE id = 4;
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
What type of Statement deletes one or more rows from a table
DELETE
57
What does the clause DELETE FROM do?
Deletes rows from a Table.
58
Explain each part of this DELETE FROM statement? DELETE FROM celebs WHERE twitter_handle IS NULL;
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
What two clauses are in a DELETE FROM statement?
DELETE FROM ______ WHERE _______ (DELETE FROM and WHERE)
60
What are Constraints?
Add information about how a column can be used or invoked after specifying the data type for a column.
61
How are Constraints used?
Used to tell the database to reject inserted data that does not adhere to a certain restriction.
62
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' );
This statement sets constraints on the celebs table.
63
What are PRIMARY KEY columns?
Uniquely identifies the row(s).
64
What would result in a constraint violation? What does it prevent?
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
What are UNIQUE columns?
Different value for every row
66
True or False: A Table can have many different UNIQUE columns.
True
67
What are NOT NULL columns?
Columns that must have a value.
68
Attempting to insert a row without a value for NOT NULL column will result in a __________ violation. The new ______ will not be inserted.
Constraint, row
69
What are DEFAULT columns?
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
A statement is a ______ of _______ that the database recognizes as a valid command.
string of characters