2024-05-01T13:45:46+03:00[Europe/Moscow] en true <p>Define relation</p>, <p>In a relation: columns are called _______, rows are called _______</p>, <p>Define (relation) schema</p>, <p>________ = picking certain rows. _________ = picking certain columns</p>, <p>Product between two relations notes</p>, <p>Define database schema</p>, <p>Creating a relation SQL notes</p>, <p>Multi-attribute primary key notes</p>, <p>Joins notes</p>, <p>USING clause example</p>, <p>not equal to operator SQL</p>, <p>EXISTS operator notes</p>, <p>ANY operator notes</p>, <p>HAVING clause example</p>, <p>Do set operators (UNION, INTERSECT, MINUS) work with relations with different schema?</p>, <p>UNION vs UNION ALL</p>, <p>Two kinds of views</p>, <p>Define view</p>, <p>Foreign key notes</p>, <p>ACID transaction properties for database systems</p>, <p>ACID transaction principles: define consistency</p>, <p>ACID transaction principles: define isolation</p>, <p>Database management system (DBMS) definition</p>, <p>Data structures used to implement data in the computer (for the database) are referred to as ____________, as opposed to conceptual models</p>, <p>Three parts of a data model</p>, <p>Can any type of value be null in SQL?</p>, <p>which is correct? </p><p>1)DROP function selectMax;</p><p>2)DROP function selectMax();</p>, <p>What is wrong here?</p>, <p>5 Aggregate functions</p>, <p>Can aggregate functions be used in the where clause?</p>, <p>Relational algebra: symbol for selection</p>, <p>Translate to relational algebra: selects rows in the table occupation where the company name is City Bank</p>, <p>π meaning in relational algebra</p>, <p>translate into relational algebra: SELECT first_name, last_name FROM employees WHERE department = 'Sales'; </p>, <p>ERD cardinality symbols</p>, <p>What operator do you use to find the difference between two relations of equal schema?</p>, <p>Using a table customers: find the names of all customerswho live in Dublin and have 'Jervis St.' theiraddress:</p>, <p>Using a table sales: find all details about salesmade in December (any year)</p>, <p>3 values in sql logic</p>, <p>Logiucally comparing any value with NULL yields ________</p>, <p>When you don't specify a type of join, an _____ join is used</p>, <p>is 'NOT IN' correct as an operator?</p>, <p>What's wrong with this query? SELECT model FROM PCs WHERE hd &lt;= 250 AND speed = MAX (speed);</p>, <p>select unique values query</p>, <p>Do nulls contribute to averages?</p>, <p>Do nulls contribute to counts?</p>, <p>If all the values in a column are null, what is the result of an aggregation?</p>, <p>Does the aggregate function here act on all the values of the column at once? Or for each group separately? SELECT customer_id , SUM (paid)FROM Sales GROUP BY customer_id</p>, <p>Fill in the blank: UPDATE PCs ____ price = 1999.0 WHERE model = '1001';</p>, <p>Three tiers in architecture for database environments </p>, <p>Database environment blob diagram</p>, <p>Cascade definition within a foreign key</p>, <p>possibilities after ON UPDATE or ON DELETE in a foreign key</p>, <p>What is the default policy of a foreign key in case of changes or deletions to the referenced value?</p>, <p>How to declare a foreign key</p>, <p>What are CHECKS (not in MySQL) similar to in MySQL?</p>, <p>How to define assertions (not supported in MySQL)</p>, <p>1NF requirements</p>, <p>2NF Requirements</p>, <p>Define partial dependency</p>, <p>3NF Requirements</p>, <p>BCNF Requirements</p>, <p>Transitive dependency definition</p>, <p>Requirement for a superkey to be a candidate key</p>, <p>Define update anomaly</p>, <p>Define deletion anomaly</p>, <p>Violating 2FA leads to a risk of ______ anomalies</p>, <p>If a functional dependency X -&gt; Y is trivial , then ___ is in ___</p>, <p>Does bcnf decomposition automatically achieve 2NF and/or 3NF?</p>, <p>BCNF decomposition steps</p>, <p>BCNF Limitations</p>, <p>3NF Synthesis algorithm</p>, <p>Reflexivity Inference rule</p>, <p>Augmentation inference rule</p>, <p>Pseudo-transitivity inference rule</p>, <p>Negatives of using indexes</p>, <p>4 data structures used for indexes</p>, <p>Key-pointer pair in a b tree definition</p>, <p>How is a b+ tree different from a b-tree?</p>, <p>B+ trees are _____ (faster/slower) than B trees for sequential access</p>, <p>Bitmap index pros and cons compared to B+ trees</p>, <p>Transaction definition</p>, <p>The SQL statement COMMIT causes a transaction to __________</p>, <p>The SQL statement ROLLBACK causes a transaction to __________</p>, <p>Serial schedule definition</p>, <p>Nonserial Schedule definition</p>, <p>Serializable Schedule definition</p>, <p>Concurrency control: locking definition</p>, <p>Concurrency control: 2 types of locks</p>, <p>Concurrency control: timestamp definition</p>, <p>What does PSM stand for?</p>, <p>Persistent stored modules (non-relational) function</p>, <p>create TRIGGER notation</p>, <p>create FUNCTION and PROCEDURE notation</p>, <p>input parameters in a function notation</p>, <p>prime attribute definition</p>, <p>how do you declare a variable within a function?</p>, <p>How do you assign the result of a query to a variable you declared in a function?</p>, <p>What should you put before BEGIN in functions/procedures?</p> flashcards
Databases

Databases

  • Define relation

    A two dimensional table within the relational model

  • In a relation: columns are called _______, rows are called _______

    attributes, tuples

  • Define (relation) schema

    The name of a relation and the set of attributes for it (including their data types, constraints(?) etc)

  • ________ = picking certain rows. _________ = picking certain columns

    Selection, projection

  • Product between two relations notes

  • Define database schema

    Set of all relation schemas in the database

  • Creating a relation SQL notes

  • Multi-attribute primary key notes

  • Joins notes

  • USING clause example

    table1 JOIN table2 USING (a_1 ,a_2 ,...,a_n )

  • not equal to operator SQL

    <>

  • EXISTS operator notes

  • ANY operator notes

  • HAVING clause example

  • Do set operators (UNION, INTERSECT, MINUS) work with relations with different schema?

    NO. Although you may be able to circumvent this by making selections from those relations so that you select equal schemas

  • UNION vs UNION ALL

    Union deletes duplicate tuples, UNION ALL suppresses this

  • Two kinds of views

    Virtual, materialized (in mySQL there is only virtual)

  • Define view

    A relation (table) defined in terms of other relations already in the database. So you essentially make a selection and assign it as a view.

  • Foreign key notes

  • ACID transaction properties for database systems

    Atomicity, Consistency, Isolation, Durability (and Access Control)

  • ACID transaction principles: define consistency

    Maintain data in a valid state at all times. -eg. no two operations share a name."–

  • ACID transaction principles: define isolation

    Keeping transaction steps separate to prevent conflict and maintain integrity /// The partial effects of incomplete transactions should not be visible to other transactions

  • Database management system (DBMS) definition

    The software that manages and controls access to the database, ie MySQL

  • Data structures used to implement data in the computer (for the database) are referred to as ____________, as opposed to conceptual models

    physical data models

  • Three parts of a data model

    Structure of the data, operations on the data, constraints on the data

  • Can any type of value be null in SQL?

    Yes

  • which is correct?

    1)DROP function selectMax;

    2)DROP function selectMax();

    1). The brackets are only used when declaring.

  • What is wrong here?

    What is wrong here?

    Missing 'READS SQL DATA' before begin

  • 5 Aggregate functions

    SUM, AVG, COUNT, MIN, MAX

  • Can aggregate functions be used in the where clause?

    No, only in the select clause

  • Relational algebra: symbol for selection

    σ

  • Translate to relational algebra: selects rows in the table occupation where the company name is City Bank

    σ(company-name = "city bank")(occupation)

  • π meaning in relational algebra

    Projection, ie where you define which columns you want

  • translate into relational algebra: SELECT first_name, last_name FROM employees WHERE department = 'Sales';

    π(first_name, last_name)(σ(employees)(department = 'Sales'))

  • ERD cardinality symbols

  • What operator do you use to find the difference between two relations of equal schema?

    MINUS

  • Using a table customers: find the names of all customerswho live in Dublin and have 'Jervis St.' theiraddress:

    SELECT firstname, lastname FROM Customers WHERE city = 'Dublin' AND address LIKE '%Jervis St.%';

  • Using a table sales: find all details about salesmade in December (any year)

    SELECT * FROM Sales WHERE day LIKE ' ____ -12%';

  • 3 values in sql logic

    TRUE, FALSE, UNKNOWN

  • Logiucally comparing any value with NULL yields ________

    UNKNOWN

  • When you don't specify a type of join, an _____ join is used

    INNER

  • is 'NOT IN' correct as an operator?

    yes

  • What's wrong with this query? SELECT model FROM PCs WHERE hd <= 250 AND speed = MAX (speed);

    MAX can only be used within a select clause. You could use a subquery.

  • select unique values query

    SELECT DISTINCT attributeFROM table;

  • Do nulls contribute to averages?

    No

  • Do nulls contribute to counts?

    No

  • If all the values in a column are null, what is the result of an aggregation?

    NULL

  • Does the aggregate function here act on all the values of the column at once? Or for each group separately? SELECT customer_id , SUM (paid)FROM Sales GROUP BY customer_id

    for each group separately

  • Fill in the blank: UPDATE PCs ____ price = 1999.0 WHERE model = '1001';

    SET

  • Three tiers in architecture for database environments

    First tier – Client (front-end)– User Interface–Second Tier - Application server (back-end)– Business logic– Data processing logic–

    Third Tier - Database server– Data validation– Database access–

  • Database environment blob diagram

  • Cascade definition within a foreign key

    If the referenced value changes/gets deleted, perform the same action on the value that references it.

  • possibilities after ON UPDATE or ON DELETE in a foreign key

    CASCADE, SET NULL, RESTRICT (don't allow it to be changed)

  • What is the default policy of a foreign key in case of changes or deletions to the referenced value?

    RESTRICT (reject)

  • How to declare a foreign key

    FOREIGN KEY (attribute) REFERENCES Table(referenced_attribute)

  • What are CHECKS (not in MySQL) similar to in MySQL?

    Foreign keys

  • How to define assertions (not supported in MySQL)

    CREATE ASSERTION <name>CHECK (<condition>);

  • 1NF requirements

    values are atomic, columns are unique, and rows are unique

  • 2NF Requirements

    There are no partial dependencies

  • Define partial dependency

    a non-key attribute of a table depends on only a part of the primary key (it is allowed to have another functional dependency with part of the primary key along with another attribute on the LHS, but not just the primary key alone)

  • 3NF Requirements

    2NF and there are no transitive dependencies. /// for each nontrivial FD X -> A that holds in R , either X is a superkey of R or A is prime

  • BCNF Requirements

    3NF and for all non-trivial FDs A-> B, A is a superkey

  • Transitive dependency definition

    a non-prime attribute depends on another non-prime attribute through a series of functional dependencies

  • Requirement for a superkey to be a candidate key

    No proper subset is a superkey

  • Define update anomaly

    When you change one occurrence of a fact in the database,but other occurrences of the same fact remain unchanged

  • Define deletion anomaly

    By deleting one fact from the database weunintentionally delete other facts as well

  • Violating 2FA leads to a risk of ______ anomalies

    deletion

  • If a functional dependency X -> Y is trivial , then ___ is in ___

    Y, X

  • Does bcnf decomposition automatically achieve 2NF and/or 3NF?

    Yes

  • BCNF decomposition steps

    1) look for a FD X with a BCNF violation

    2) Compute {X}+

    3) Replace the relation R by two relations with schemas: R1 = X+ ; R2 = R - (X+ - X)

  • BCNF Limitations

    separation of data that usually goes together can make FDs impossible to enforce

  • 3NF Synthesis algorithm

    Step 0. Find all keys of R and check if any FD in Fviolates 3NF. If a violation is present then proceed with Step 1. Otherwise stop.

    Step 1. Find a minimal basis G.

    Step 2. For each left side of the FDs in the minimal basis, create a new relation with attributes being the closure of the left side.

  • Reflexivity Inference rule

    Reflexivity : if B ⊆ A then A → B

  • Augmentation inference rule

    Augmentation : if A → B then AC → B

  • Pseudo-transitivity inference rule

    if A → B and BC → D then AC → D

  • Negatives of using indexes

    Data modification takes longer, as indexes need to be adjusted too

  • 4 data structures used for indexes

    B+ trees, B-trees, Bitmap indexes, Hash tables

  • Key-pointer pair in a b tree definition

    the key is the representation of the value in the tree, the pointer points to the location of the actual value in the table

  • How is a b+ tree different from a b-tree?

    1) Internal nodes only contain keys, no pointers.

    2) Leaf nodes contain key-pointer pairs AND pointers to their right sibling

    3) all keys appear in leaf nodes and some keys appear in internal nodes

  • B+ trees are _____ (faster/slower) than B trees for sequential access

    faster

  • Bitmap index pros and cons compared to B+ trees

    + Faster access time

    + Less storage space

    - Slower update time

  • Transaction definition

    a logical unit of work on the database, which should transform it from one consistent state to another

  • The SQL statement COMMIT causes a transaction to __________

    complete

  • The SQL statement ROLLBACK causes a transaction to __________

    end, by aborting (no changes are made)

  • Serial schedule definition

    a schedule where the operations of each transaction are executed consecutively without any interleaved operations from other transactions.

  • Nonserial Schedule definition

    a schedule where the operations from a set of concurrent transactions are interleaved

  • Serializable Schedule definition

    a nonserial schedule that produces the same result as some serial schedule

  • Concurrency control: locking definition

    When one transaction is accessing the database, a lock may deny access to other transactions to prevent incorrect results

  • Concurrency control: 2 types of locks

    Shared (transaction with the lock can read but not update), and exclusive (only the transaction with the lock can read and update)

  • Concurrency control: timestamp definition

    A unique identifier created by the DBMS that indicates the relative starting time of a transaction

  • What does PSM stand for?

    persistent stored modules

  • Persistent stored modules (non-relational) function

    allows for the storage of procedures as database schema elements

  • create TRIGGER notation

  • create FUNCTION and PROCEDURE notation

  • input parameters in a function notation

    (IN testInput type, IN testInput2 type)

  • prime attribute definition

    An attribute that is part of a candidate key

  • how do you declare a variable within a function?

    DECLARE testVar type;

  • How do you assign the result of a query to a variable you declared in a function?

    SELECT ______ INTO variable FROM ______ WHERE

  • What should you put before BEGIN in functions/procedures?

    MODIFIES SQL DATA / READS SQL DATA / DETERMINISTIC