Relational Databases: Structured Query Language

Relational Databases: Structured Query Language

memorize.aimemorize.ai (lvl 286)
Section 1

Preview this deck

INT

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (59)

Section 1

(50 cards)

INT

Front

Integer (no decimal) between -2147483648 to 2147483647

Back

False

Front

Views cannot be updated

Back

View materialization

Front

a physical table is created when the view is first queried

Back

FLOAT(n, d)

Front

Small number with a floating decimal point. The total maximum number of digits is n with a maximum of d digits to the right of the decimal point.

Back

Simple Queries

Front

SQL statements that retrieve data from only one table

Back

PRIMARY KEY

Front

constraint defines the primary key of the table

Back

Join Queries

Front

•Inner Joins •Outer Joins

Back

Queries with Aggregate Functions

Front

COUNT, SUM, AVG, VARIANCE, MIN/MAX, STDEV

Back

SQL INSERT Statement

Front

INSERT INTO PRODUCT VALUES ('980', 'Chateau Angelus, Grand Clu Classé, 1960', 'red', 6)

Back

Column constraints

Front

PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, DEFAULT, CHECK

Back

UNIQUE

Front

constraint defines an alternative key of a table

Back

Nested Query example

Front

SELECT SUPNAME FROM SUPPLIER WHERE SUPNR = (SELECT SUPNR FROM PURCHASE_ORDER WHERE PONR = '1560')

Back

Queries with Set Operations

Front

SELECT SUPNR FROM SUPPLIER EXCEPT SELECT SUPNR FROM SUPPLIES

Back

Key Characteristics of SQL

Front

- Set-oriented and declarative - Free form language - Case insensitive - Can be used interactively from a command prompt or executed by a program

Back

DEFAULT

Front

constraint sets a default value for a column

Back

VARCHAR(n)

Front

Holds a variables length string with a maximum size n

Back

Queries with EXISTS

Front

SELECT SUPNAME FROM SUPPLIER R WHERE EXISTS (SELECT * FROM SUPPLIES S WHERE R.SUPNR = S.SUPNR AND S.PRODNR = '0178')

Back

relation

Front

SQL table implements a ____ from the relational model

Back

SMALLINT

Front

Small integer (no decimal) between -32768 to 32767

Back

SQL Views

Front

- Part of the external data model - Defined by means of an SQL query and its content is generated upon its invocation by an application or other query - A virtual table without physical tuples - Allow for logical data independence which makes them a key component in the three-layer database architecture

Back

Inner Join example

Front

SELECT R.SUPNR, R.SUPNAME, R.SUPSTATUS, S.PRODNR, S.PURCHASE_PRICE FROM SUPPLIER R, SUPPLIES S WHERE R.SUPNR = S.SUPNR

Back

SELECT STATEMENT FORMAT

Front

SELECT component FROM component [WHERE component] [GROUP BY component] [HAVING component] [ORDER BY component]

Back

BOOLEAN

Front

True or False

Back

TRUE

Front

SQL does not eliminate duplicates

Back

FOREIGN KEY

Front

constraint defines a foreign key of a table

Back

Outer Joins

Front

- Joins that work even with NULL values - Can be used when we want to keep all the tuples of one, or both tables, in the result of the JOIN, regardless of whether or not they have matching tuples in the other table

Back

Correlated Queries

Front

- Whenever a condition in the WHERE clause of a nested query references some column of a table declared in the outer query •The nested query is then evaluated once for each tuple (or combination of tuples) in the outer query

Back

CHAR(n)

Front

Holds a fixed length string with size n

Back

DATETIME

Front

Date and time in format YYYY-MM-DD HH:MI:SS

Back

multiset

Front

Result of SQL SELECT statement

Back

DOUBLE(n, d)

Front

Large number with a floating decimal point. The total maximum number of digits is n with a maximum of d digits to the right of the decimal point.

Back

DATE

Front

Date in format YYYY-MM-DD

Back

SQL DML statements

Front

SQL SELECT, SQL INSERT, SQL DELETE, SQL UPDATE

Back

Simple Query example

Front

SELECT * FROM SUPPLIER

Back

NOT NULL

Front

constraint prohibits NULL values for a column

Back

DROP

Front

command can be used to drop or remove database objects

Back

SQL DELETE Statement

Front

DELETE FROM PRODUCT WHERE PRODNR = '1000'

Back

Outer Join example

Front

SELECT R.SUPNR, R.SUPNAME, R.SUPSTATUS, S.PRODNR, S.PURCHASE_PRICE FROM SUPPLIER AS R LEFT OUTER JOIN SUPPLIES AS S ON (R.SUPNR = S.SUPNR)

Back

SQL VIEW Statement example

Front

CREATE VIEW TOPSUPPLIERS AS SELECT SUPNR, SUPNAME FROM SUPPLIER WHERE SUPSTATUS > 50

Back

Queries with GROUP BY/HAVING

Front

SELECT PRODNR, SUM(QUANTITY) AS QUANTITY FROM PO_LINE GROUP BY PRODNR HAVING SUM(QUANTITY) > 15

Back

SQL Schema

Front

grouping of tables and other database objects such as views, constraints and indexes which logically belong together

Back

TIME

Front

Time in format HH:MI:SS

Back

BLOB

Front

Binary Large Object (e.g. image, audio, video)

Back

ALTER

Front

statement can be used to modify table column definitions

Back

Queries with ALL/ANY

Front

•The comparison condition v > ALL V returns TRUE if the value v is greater than all the values in the multiset V -If the nested query doesn't return a value, it evaluates the condition as TRUE •The comparison condition v > ANY V returns TRUE if the value v is greater than at least one value in the multiset V -If the nested query doesn't return a value, it evaluates the whole condition as FALSE

Back

Query modification

Front

RDBMS modifies queries that query views into queries on the underlying base tables

Back

CHECK

Front

constraint defines a constraint on the column values

Back

Queries with ORDER BY

Front

SELECT PONR, PODATE, SUPNR FROM PURCHASE_ORDER ORDER BY PODATE ASC, SUPNR DESC

Back

Inner Joins

Front

Joins that display data if there were a corresponding record in each table queried. Equality joins, non-equality joins, and self-joins are all classified as inner joins.

Back

SQL UPDATE Statement

Front

UPDATE SUPPLIER SET SUPSTATUS = DEFAULT

Back

Section 2

(9 cards)

GRANT INSERT

Front

Gives insert privilege

Back

SQL Privilege(s)

Front

Corresponds to the right to use certain SQL statements such as SELECT, INSERT, ect. on one or more database objects

Back

GRANT DELETE

Front

Gives delete privilege

Back

GRANT ALTER

Front

Gives privilege to change the table definition

Back

GRANT SELECT

Front

Provides retrieval privilege

Back

GRANT REFERENCES

Front

Provides the privilege to reference the table when specifying integrity constraints

Back

GRANT ALL

Front

Provides all privileges (DBMS specific)

Back

REVOKE

Front

Removes a specified privilege

Back

GRANT UPDATE

Front

Gives update privilege

Back