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)
2
Q
SQL Use
A
- Create databases
- Add, modify & delete a) database structures & b) records in database
- Query databases (data retrieval)
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
4
Q
SQL Commands Categories
A
- Data Definition Language (DDL)
create & modify structure of database e.g. CREATE, ALTER, DROP - Data Manipulation Language (DML)
Insert, modify, delete & retrieve data e.g. INSERT TO, UPDATE, DELETE, SELECT - Data Control Language (DCL)
- Transactional Control Language (TCL)
5
Q
SQL data types
A
- Each column of each SQL created relation has a specific data type
6
Q
CHAR(n)
A
fixed length n-character string
7
Q
VARCHAR(n)
A
variable length character string with max. size of n characters
8
Q
NUMERIC(x,y)
A
number with x digitis, y of which are after decimal point
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…)
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
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 ;
12
Q
Renaming
A
- renaming columns that appear in result
- e.g. p.productid pid, v.vendorname vname FROM product p, vendor v ;
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
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
15
Q
Absolute value of x
A
ABS(x)