VA Session 3 & 4 Flashcards

1
Q

SQL

A
  • Structured Query Language
  • standard relational database language (can be used with majority of relational DBMS software tools)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

SQL Use

A
  • Create databases
  • Add, modify & delete a) database structures & b) records in database
  • Query databases (data retrieval)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Case sensitivity

A
  • No: keywords, table & column names – SELECT = select = SeLeCt; but commands usually written with capital letters, table etc. names small
  • yes: Values of columns with textual types
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

SQL Commands Categories

A
  1. Data Definition Language (DDL)
    create & modify structure of database e.g. CREATE, ALTER, DROP
  2. Data Manipulation Language (DML)
    Insert, modify, delete & retrieve data e.g. INSERT TO, UPDATE, DELETE, SELECT
  3. Data Control Language (DCL)
  4. Transactional Control Language (TCL)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

SQL data types

A
  • Each column of each SQL created relation has a specific data type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

CHAR(n)

A

fixed length n-character string

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

VARCHAR(n)

A

variable length character string with max. size of n characters

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

NUMERIC(x,y)

A

number with x digitis, y of which are after decimal point

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

Subqueries

A
  • queries within a larger SQL query
  • Inner queries used to return information that will be use by outer query
  • Enclosed by ()
  • usually added within WHERE clause of outer query
  • e.g. SELECT … FROM … WHERE … IN (SELECT … FROM …. WHERE…)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Joining data from several datas - ways

A
  • 1) WHERE clause
  • 2) JOIN clause (sometimes preferred due to readability)
  • 3) operators as UNION or INTERSECTION
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Alias

A
  • Alternative name usable in a query instead of full name
  • Pro: shorter & if 2 tables have same name
  • e.g. SELECT p.productid, v.vendorname FROM product p, vendor v ;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Renaming

A
  • renaming columns that appear in result
  • e.g. p.productid pid, v.vendorname vname FROM product p, vendor v ;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Views

A
  • Mechanism in SQL to save structure of a query in RDBMS
  • virtue table <-> not actual table: if view invoked, executes a query & retrieves data from table
  • virtual table whose contents are defined by a query
  • used to focus, simplify, and customize the perception each user has of the database
  • security mechanisms by letting users access data through the view, without granting the users permissions to directly access the underlying base tables of the view
  • Like table: view consists of a set of named columns and rows of data that come from tables referenced in the query defining the view and are produced when view referenced
  • acts as a filter on the underlying tables referenced in the view
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Set operators

A
  • combine results of >= 2 SELECT statements (, querying relations, views or other SELECT queries) that are union compatible (= contain same number of columns & data types of columns in sets match)
  • Union, intersection & difference
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Absolute value of x

A

ABS(x)

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

Length of string s

A

LENGTH(s)
e.g. Return products with name that has 5 characters:
SELECT *
FROM Products
WHERE LENGTH(name) = 5;

17
Q

Converts string s to lowercase & uppercase

A

LOWER(s)
UPPER(s)

18
Q

Larger & smaller value of x and y

A

MAX(x,y)
MIN(x,y)

19
Q

Produces a random number

A

RANDOM()

20
Q

Number x rounded to d decimal places

A

ROUND(x,d)

21
Q

Calculating a cumulative

A

SUM

22
Q

Null returned

A

there is no value returned with the query (!= 0 -> if at any point of calculation / comparison NULL, the result will be NULL)