InLearning - Essential SQL Flashcards

1
Q

CRUD

A

Create, Read, Update, Delete

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

SQL

A

Structured Query Language

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

DSL

A

Domain Specific Language

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

GPL

A

General Purpose Language

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

RDBMS

A

Relational Data Base Management System

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

RDSMS

A

Relational Data Stream Management System

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

DSMS

A

Data Stream Management System

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

an SQL statement is terminated with a

A

;

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

ASCII

A

American Standard Code for Information Exchange

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

single quotes are for

A

alias identifier

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

How do you pick columns?

A

SELECT

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

How do select rows?

A

WHERE

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

What is dynamic memory?

A

Dynamic memory allocation is when an executing program requests that the operating system give it a block of main memory. The program then uses this memory for some purpose. Usually the purpose is to add a node to a data structure.

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

SID

A

Security Identifier

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

ANSI

A

American National Standards Institute

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

ISO

A

Interational Organization for Standardization

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

SQL was developed at ___ by ___.

A

IBM, Chamberlain & Boyce

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

Who did the relational model?

A

Tedd Codd

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

SEQUEL

A

Structured English Query Language

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

What was Oracle’s first name?

A

Relational Software Inc,

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

A table has rows and columns, where rows represent ___ and columns represent the ___.

A

A table has rows and columns, where rows represent records and columns represent the attributes.

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

Tuple

A

Tuple − A single row of a table, which contains a single record for that relation is called a tuple.

In mathematics, a tuple is a finite ordered list (sequence) of elements. Mathematicians usually write tuples by listing the elements within parentheses “ {\displaystyle ({\text{ }})} (\text{ })” and separated by commas; for example, {\displaystyle (2,7,4,1,7)} (2, 7, 4, 1, 7) denotes a 5-tuple.

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

Schema

A

The term “schema” refers to the organization of data as a blueprint of how the database is constructed (divided into database tables in the case of relational databases).

A representation of a plan or theory in the form of an outline or model.

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

ALTER TABLE Statement is used to ___, ___, or ___ ___ in an existing table.

A

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.

The ALTER TABLE statement is also used to add and drop various constraints on an existing table.

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

How do you create rows of data

A

INSERT INTO test (a,b) VALUES (10,’a’);

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

How do you create an ID Column?

A

INTEGER PRIMARY KEY

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

What is a Boolean data type?

A

This has three values: TRUE, FALSE, and UNKNOWN. Expressions that return aBoolean data type are known as Boolean expressions. Unlike other SQL Server data types, a Boolean data type cannot be specified as the data type of a table column or variable, and cannot be returned in a result set.

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

BOOLEAN

A

This has three values: TRUE, FALSE, and UNKNOWN. Expressions that return a Boolean data type are known as Boolean expressions. Unlike other SQL Server data types, a Boolean data type cannot be specified as the data type of a table column or variable, and cannot be returned in a result set.

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

What is the wild card?

A

% at beginnning or end

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

How to use underscore.

A

before a letter _a (means second letter is a)

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

WHERE clause allows you to get just the ___ you need

A

rows

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

DISTINCT

A

to find distinct values

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

four kinds of JOIN

A

Inner, Outer, Left, Right

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

Alias Identifier syntax

A

SELECT * FROM table_name [AS] alias_name

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

A table alias is also called a ___.

A

A table alias is also called a correlation name.

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

What is a CLAUSE?

A

???

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

junction table

A

???

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

LENGTH

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

SUBSTR

A

unpack data from a column

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

TRIM

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

how to view source

A

CTRL+U

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

INSERT INTO

A

The INSERT INTO statement is used to insert new records in a table.

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

UPPER and LOWER funtions

A

make capital or lower case

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

use of operator “=”

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

what are the two number types

A

integer and real

46
Q

floating point numbers sacrifice

A

something for percision

47
Q

TYPEOF

A
48
Q

catenate/concatenate

A
49
Q

CAST

A
50
Q

MODULUS operator

A
51
Q

ROUND

A
52
Q

SQL Standard date & time formate

A
53
Q

SQL Lite

A
54
Q

COUNT

A

aggregate???

55
Q

HAVING clause

A
56
Q

TRANSACTION

A
57
Q

TRIGGER

A
58
Q

A database is a collection of information

A
59
Q

NULL means?

A

Nothing here.

60
Q

The COUNT() function returns the number of rows that matches a specified criteria.

A

SELECT COUNT(column_name)
FROM table_name
WHERE condition;

61
Q

The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions.

A
62
Q

HAVING syntax

A

SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);

63
Q

ORDER BY Syntax

A

SELECT column1, column2, …
FROM table_name
ORDER BY column1, column2, … ASC|DESC;

64
Q

LENGTH

A

counts numbers or characters

65
Q

SUBSTING (?, ?, ?)

A
66
Q

Alias

A

AS

67
Q

You can’t create a field w/o giving it a ___.

A

Data Type

68
Q

Dates are tricky because ___.

A

Different formats.

69
Q

Your database has a table called orders, containing a field called order_num. Which is a correctly formed query in MySQL?

A

select order_num from orders

70
Q

What does zero-indexing mean in a database?

A

Database software typically starts counting rows at zero, irrespective of the id number stored in the row.

71
Q

The following statement will return all orders other than the one with an id of 5 (in MySQL): select * from orders where order_id<>5

A

TRUE

72
Q

What would the following query return? SELECT order_id FROM orders WHERE order_num<5 AND order_type=’online’ OR order_type=’cash’

A

Rows with both id<5 and order_type of ‘online’, plus all rows with order_type of ‘cash’ regardless of id.

73
Q

What’s the best description of an SQL string function?

A

It is like a formula, applied to a field to change some or all characters within all rows returned, e.g. to make all characters upper case.

74
Q

Assuming a table called cities contains a field called city, what will the following query return in MySQL? SELECT SUBSTRING(city,1,1) FROM cities WHERE city=”London”One or more rows containing the letter L.

A

One or more rows containing the letter L.

75
Q

Using an alias on a field name can change the column heading in the result set.

A

TRUE

76
Q

Databases store data, plus data about the data. One of the key kinds of latter data is data type. There are scores of data types. The database will not let you create a field without its data type.

A

TRUE

77
Q

In SQL queries it’s rare to specify a WHERE clause in this format (MySQL): WHERE field_name = ‘2016-07-07’. Why?

A

Because we don’t know what kind of date field_name is: it might require a time as well as date, in which case we would get a false result.

78
Q

Aggregation functions

A
79
Q

SELECT

FROM

GROUP BY

A
80
Q

SELECT DISTINCT

A

to removed repeated values

81
Q

How do you find how many customers you have?

A

SELECT DISTINCT customers

FROM table1

82
Q

Why is the following query poorly formed? SELECT *, count(*) FROM address

A

Because it mixes grouped and ungrouped results. Reading across the single row of results will suggest the count value belongs to that row.

83
Q

Which of these queries is in the right order?

A

SELECT district, count(district) as ct FROM address WHERE district like ‘%B%’ GROUP BY district HAVING count(district)>8 ORDER BY ct DESC

84
Q

SELECT DISTINCT is used to return unique values. You can use it to return unique combinations by listing the relevant fields after the word DISTINCT, separated by commas.

A

TRUE

85
Q

INSERT INTO syntax

A

INSERT INTO table_name (column1, column2, column3, …)
VALUES (value1, value2, value3, …);

Example:

INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES (‘Cardinal’, ‘Tom B. Erichsen’, ‘Skagen 21’, ‘Stavanger’, ‘4006’, ‘Norway’);

86
Q

ALTER TABLE syntax

A

ALTER TABLE table_name
ADD column_name datatype;

87
Q

What SQL statement extracts data from a database?

A

SELECT

88
Q

Which SQL statement is used to update data in a database?

A

UPDATE

89
Q

Which SQL statement is used to delete data from a database?

A

SELECT

90
Q

LIMIT

A
91
Q

JOIN

A
92
Q

If you JOIN a 5 row table to a 6 row table, why might you only get 4 rows?

A

Because those are the only rows that are the same.

93
Q

JOIN and ON are part of the ___ section of the query.

A

FROM

94
Q
A
95
Q

JOIN merges ___, UNION merges ___.

A

columns, rows

96
Q

The IN operator allows you to specify multiple values in a ___ clause.

A

The IN operator allows you to specify multiple values in a WHERE clause.

97
Q

IN Syntax

A

SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1, value2, …);

98
Q

A field in one table that appears as a field in another table is probably ___.

A

A field in one table that appears as a field in another table is probably a foreign key .

99
Q

There is usually only one primary key in a table. It is typically has data type set to ___ and is set to ___.

A

There is usually only one primary key in a table. It is typically has data type set to integer (int) and is set to auto-increment .

100
Q

To make sense of an unfamiliar database, it’s helpful to visualise it by following the trail of ___.

A

To make sense of an unfamiliar database, it’s helpful to visualise it by following the trail of foreign keys .

101
Q

Different types of join determine which rows are included from which tables. To return rows that exist in both tables you would use a(n) ___.

A

Different types of join determine which rows are included from which tables. To return rows that exist in both tables you would use a(n) INNER JOIN .

102
Q

T/F. UNION will display rows from both queries, one under the other. Unique values are returned with UNION while all values are returned with UNION ALL.

A

TRUE

103
Q

T/F. We can return the same results as JOIN using IN like so: SELECT * from table where field2 in (SELECT field2 from table2)

A

FALSE

104
Q

A VIEW is a ___.

A

stored query

105
Q
A
106
Q

Which is the best definition of a view in SQL?

A

A stored query, which runs and returns a tabular result set when you click on it or refer to it in a query. Like a virtual table.

107
Q

Which is the best definition of a function in SQL?

A

A stored calculation, which returns one or more values when you refer to it in a query.

108
Q

Which is the best definition of a stored procedure in SQL?

A

A stored query, which returns a value or performs an action, when called in a query.

109
Q

ACID compliant

A
110
Q

normalized

A
111
Q
A