Docsity

WGU IT D426 Data Management Foundations | Study Guide, OA Exam Prep, SQL, Databases & Norm, Assignments of Information Technology

Toggle sidebar
bg1
D426 Database Management Foundations Terms Study Guide
1.1 Database basics
database application
oA database application is software thathelpsbusinessusers
interact with database systems.
database administrator
oA database administrator is responsible forsecuring the
database system against unauthorized users. A database
administrator enforces procedures for user access and database
system availability.
1.2 Database systems
Authorization
o. Many database users should havelimited accessto specific
tables, columns, or rows of a database. Database systems
authorize individual users to access specific data.
Rules
oDatabase systems
ensuredataisconsistentwithstructuralandbusiness rules.
query processor
oThe query processorinterprets queries, creates a planto
modify the database or retrieve data, and returns query results
to the application.
query optimization
oThe query processor performs query optimization to ensure the
mostefficient instructions are executedon the data.
storage manager
oThe storage managertranslates the query processor
instructionsintolow-levelfile-systemcommandsthat modify
or retrieve data.
indexes
oThestorage manager uses indexes to quickly locate data.
transaction manager
oThe transaction managerensures transactions are properly
executed.
Metadata
oMetadata isdata about the database, such ascolumn
namesand thenumber of rowsin each table.
relational database
oA relational databasestores data in tables, columns, and
rows, similar to a spreadsheet.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c

Partial preview of the text

Download WGU IT D426 Data Management Foundations | Study Guide, OA Exam Prep, SQL, Databases & Norm and more Assignments Information Technology in PDF only on Docsity!

D426 Database Management Foundations Terms Study Guide 1.1 Database basicsdatabase application o A database application is software that helps business users interact with database systems.  database administrator o A database administrator is responsible for securing the database system against unauthorized users. A database administrator enforces procedures for user access and database system availability. 1.2 Database systemsAuthorization o. Many database users should have limited access to specific tables, columns, or rows of a database. Database systems authorize individual users to access specific data.  Rules o Database systems ensure data is consistent with structural and business rules.  query processor o The query processor interprets queries, creates a plan to modify the database or retrieve data, and returns query results to the application.  query optimization o The query processor performs query optimization to ensure the most efficient instructions are executed on the data.  storage manager o The storage manager translates the query processor instructions into low-level file-system commands that modify or retrieve data.  indexes o The storage manager uses indexes to quickly locate data.  transaction manager o The transaction manager ensures transactions are properly executed.  Metadata o Metadata is data about the database , such as column names and the number of rows in each table.  relational database o A relational database stores data in tables, columns, and rows , similar to a spreadsheet.

o All relational database systems support the SQL query language.  relational databases are good for what? o Relational systems are ideal for databases that require an accurate record of every transaction, such as banking, airline reservation systems, and student records.SQL o SQL stands for Structured Query Language and includes statements that read and write data, create and delete tables, and administer the database system. o All relational database systems support the SQL query language.  big data o The growth of the internet in the 1990s generated massive volumes of online data, called big data, often with poorly structured or missing information. o MongoDB: big data, open source, noSQL.  NoSQL o The newer non-relational systems are called NoSQL, for 'not only SQL', and are optimized for big data. o MongoDB: big data, open source, noSQL 1.3 Query languagesINSERT o INSERT inserts rows into a table. INSERT INTO table_name (column_name1, column_name2, ...) VALUES (DEFAULT, 'bob', 30, 150);  SELECT o SELECT retrieves data from a table. SELECT column1, column2, ... FROM table_name; -- return all data from those columns.  UPDATE o UPDATE modifies data in a table. UPDATE table_name SET column_name = 2 WHERE column_id = 3;  DELETE o DELETE deletes rows from a table. DELETE FROM table_name; -- all rows deleted! DELETE FROM table_name WHERE column_name = 'value'; -- delete row  CREATE TABLE

o The logical design phase implements database requirements in a specific database system. o For relational database systems, logical design converts entities, relationships, and attributes into tables, keys, and columns. o The logical design, as specified in SQL and depicted in a table diagram, is called a database schema. o  key o A key is a column used to identify individual rows of a table. o Tables, keys, and columns are specified in SQL with CREATE TABLE statements.  database design: physical design o The physical design phase adds indexes and specifies how tables are organized on storage media. o Physical design affects query processing speed but never affects the query result.  data independence o The principle that physical design never affects query results is called data independence. o Physical design affects query processing speed but never affects the query result. o When database designers modify indexes or row order, applications run faster or slower but always generate the same results.  application programming interface / API o simplify the use of SQL with a general-purpose language. o An application programming interface, or API, is a library of procedures or classes that links a host programming language to a database. 1.5 MySQLMySQL Command-Line Client o The MySQL Command-Line Client is a text interface included in the MySQL Server download.

o The Command-Line Client allows developers to connect to the database server, perform administrative functions, and execute SQL statements. o o MYSQL Community sometimes includes the 'world' database, a database to practice with.  root account o The root account, the administrative account that has full control of MySQL.  error code o MySQL Server returns an error code and description when an SQL statement is syntactically incorrect or the database cannot execute the statement. 2.01 Relational modelrelational database o A database model is a conceptual framework for database systems, with three parts:  Data structures : that prescribe how data is organized.

Relational Operations: SELECT, JOIN, UNION, AGGREGATE o SELECT selects a subset of rows of a table. o JOIN combines two tables by comparing related columns. o UNION selects all rows of two tables. o AGGREGATE computes functions over multiple table rows, such as sum and count.  Business rules o Rules are logical constraints that ensure data is valid. o Business rules are based on business policy and specific to a particular database. o e.g. All rows of the 'Employee' table must have a valid entry in the 'DepartCode' column. 2.02 Structured Query LanguageStructured Query Language / SQL o Structured Query Language (SQL) is a high-level computer language for storing, manipulating, and retrieving data. o SQL is the standard language for relational databases , and is commonly supported in non-relational databases.  SQL Statement Literals: Strings, Numbers, Binary o Explicit values that are string, numeric, or binary.  Strings must be surrounded by single quotes or double quotes. e.g. 'string' or "string".  Numeric. 123  Binary values are represented with x'0' where the 0 is any hex value. e.g. x'ofa2'.  Data Definition Language o Data Definition Language (DDL) defines the structure of the database. o CREATE, ALTER, DROP  Data Manipulation Language o Data Manipulation Language (DML) manipulates data stored in a database. o INSERT, UPDATE, DELETE  Data Query Language o Data Query Language (DQL) retrieves data from the database. o SELECT  Data Control Language o Data Control Language (DCL) controls database user access. o GRANT, REVOKE  Data Transaction Language

o Data Transaction Language (DTL) manages database transactions. o SAVEPOINT, ROLLBACK, COMMIT 2.04 Tablestable o A table has a name, a fixed sequence of columns(tuple) , and a varying set of rows.  table rules o Exactly one value per cell. A cell may not contain multiple values. Unknown data is represented with a special NULL value. o No duplicate column names. Duplicate column names are allowed in different tables, but not in the same table. o No duplicate rows. No two rows may have identical values in all columns. o No row order. Rows are not ordered. The organization of rows on a storage device, such as a disk drive, never affects query results.  data independence. Data independence allows database administrators to improve query performance by changing the organization of data on storage devices , without affecting query results.  column o A column has a name and a data type.  row o A row is an unnamed sequence of values. Each value corresponds to a column and belongs to the column's data type.  cell o A cell is a single column of a single row.  empty table o A table without rows is called an empty table.  data independence o Data independence allows database administrators to improve query performance by changing the organization of data on storage devices , without affecting query results.  CREATE TABLE o DDL o The CREATE TABLE statement creates a new table by specifying the table name, column names, and column data types. CREATE TABLE Employee ( ID INT NOT NULL UNSIGNED,

Data type Stora ge TINYINT 1 byte SMALLINT

bytes MEDIUMIN T

bytes INTEGER or INT

bytes BIGINT

bytes 2.06 Selecting rowsoperator / operands o An operator is a symbol that computes a value from one or more other values, called operands:  Arithmetic operators compute numeric values from numeric operands.  Comparison operators compute logical values TRUE or FALSE. Operands may be numeric, character, and other data types.  Logical operators compute logical values from logical operands. o Operato r Description Examp le Valu e

  • Adds two numeric values 4 + 3 7

Operato r Description Examp le Valu e

  • (unary) Reverses the sign of one numeric value -(-2) 2

(binary) Subtracts one numeric value from another

  • Multiplies two numeric values 3 * 5 15 / Divides one numeric value by another 4 / 2 2 % (modulo) Divides one numeric value by another and returns the integer remainder

^

Raises one numeric value to the power of another

5^2 25

= Compares two values for equality 1 = 2

FALS

E

!= Compares two values for inequality 1 != 2

TRU

E

Operator precedence o higher more precedence. PEDMAS. o OR has the least precedence. Operator/ Element Description () parens ^ exponentiation

  • / % multiplication, division, modulo
    • addition, subtraction BETWEEN IN LIKE range containment, set membership, string matching < > = <= >= <> comparison operators IS ISNULL

IS TRUE, IS FALSE, IS NULL, IS DISTINCT

FROM, etc.

2.09 Primary keysprimary key o A primary key is a column, or group of columns, used to identify a row. o The primary key is usually the table's first column and appears on the left of table diagrams, but the position is not significant to the database. o Primary keys (simple or composite) must be :  UNIQUE. This rule ensures that each value identifies at most one row.  NOT NULL. This rule ensures that each value identifies at least one row.  simple primary key o A simple primary key consists of a single column. CREATE TABLE Employee ( ID SMALLINT NOT NULL UNIQUE UNSIGNED, Name VARCHAR(60), Salary DECIMAL(7,2), PRIMARY KEY (ID) );  composite primary key o A composite primary key consists of multiple columns. CREATE TABLE Family ( ID SMALLINT NOT NULL UNIQUE UNSIGNED, Number SMALLINT NOT NULL UNIQUE UNSIGNED, Relationship VARCHAR(20), Name VARCHAR(60), PRIMARY KEY(ID, Number) );  auto-increment o An auto-increment column is a numeric column that is assigned an automatically incrementing value when a new row is inserted. o AUTO_INCREMENT  The AUTO_INCREMENT keyword defines an auto- increment column. AUTO_INCREMENT follows the column's data type in a CREATE TABLE statement.  Database users occasionally make the following errors when inserting primary keys:  Inserting values for auto-increment primary keys.

 Omitting values for primary keys that are not auto- increment columns.  MySQL allows insertion of a specific value to an auto-increment column. However, overriding auto- increment for a primary key is usually a mistake. CREATE TABLE Employee ( ID SMALLINT NOT NULL UNSIGNED AUTO_INCREMENT, Name VARCHAR(60), BirthDate DATE, Salary DECIMAL(7,2), PRIMARY KEY (ID) ); 2.10 Foreign keysforeign key o A foreign key is a column, or group of columns, that refer to a primary key. o  FOREIGN KEY / REFERENCES o A foreign key constraint is added to a CREATE TABLE statement with the FOREIGN KEY and REFERENCES keywords. o When a foreign key constraint is specified, the database rejects insert, update, and delete statements that violate referential integrity. CREATE TABLE Department ( Code TINYINT NOT NULL UNIQUE UNSIGNED, Name VARCHAR(20), ManagerID SMALLINT UNSIGNED, PRIMARY KEY (Code), FOREIGN KEY (ManagerID) REFERENCES EmployeeTable(ID) ); 2.11 Referential integrityfully NULL

o The database automatically rejects insert, update, and delete statements that violate a constraint. o NOT NULL o DEFAULT o PRIMARY KEY o FOREIGN KEY CREATE TABLE Employee ( ID INT, Name VARCHAR(20) NOT NULL, -- NOT NULL, Column Constraint DepartmentCode INT DEFAULT 999, PRIMARY KEY (ID), -- Column or Table Constraint FOREIGN KEY (DepartmentCode) REFERENCES Department (Code) -- Table Constraint );  UNIQUE o The UNIQUE constraint ensures that values in a column, or group of columns, are unique. CREATE TABLE Employee ( ID SMALLINT UNSIGNED, Name VARCHAR(60), Extension CHAR(4), Username VARCHAR(50) UNIQUE, UNIQUE (Name, Extension), PRIMARY KEY (ID) );  CHECK o The CHECK constraint specifies an expression on one or more columns of a table. The constraint is violated when the expression is FALSE and satisfied when the expression is either TRUE or NULL. CREATE TABLE Employee ( ID SMALLINT UNSIGNED, Name VARCHAR(60), BirthDate DATE, HireDate DATE CHECK (HireDate >= '2000-01-01' AND HireDate <= '2019-12-31'), Size VARCHAR(6) CHECK (Size IN ('small', 'medium', 'large')), CHECK (BirthDate < HireDate), PRIMARY KEY (ID) );

 SQL CONSTRAINT

o Table constraints may be named using the optional CONSTRAINT keyword, followed by the constraint name and declaration o Adding and dropping constraints  Constraints are added and dropped with the ALTER TABLE TableName followed by an ADD, DROP, or CHANGE clause. CREATE TABLE Employee ( ID INT, Name VARCHAR(20) NOT NULL, DepartmentCode INT DEFAULT 999, CONSTRAINT EmployeePK PRIMARY KEY (ID), CONSTRAINT EmployeeDepartmentFK FOREIGN KEY (DepartmentCode) REFERENCES Department (Code) ); -- Query Statement SELECT Column_Name, Constraint_Name FROM Employee WHERE EmployeePK = 1; 3.1 Special operators and clausesBETWEEN o The BETWEEN operator provides an alternative way to determine if a value is between two other values. The operator is written value BETWEEN minValue AND maxValue and is equivalent to: o value >= minValue AND value <= maxValue. // These are both inclusive. Includes both minValue and maxValue. SELECT Name FROM Employee WHERE HireDate BETWEEN '2000-01-01' AND '2020-01-01'; -- inclusive both.  LIKE o The LIKE operator, when used in a WHERE clause, matches text against a pattern using the two wildcard characters % and _. o % matches any number of characters. e.g. LIKE 'L%t' matches "Lt", "Lot", "Lift", and "Lol cat". o _ matches exactly one character. e.g. LIKE 'L_t' matches "Lot" and "Lit" but not "Lt" and "Loot".

3.3 Aggregate functionsaggregate function o An aggregate function processes values from a set of rows and returns a summary value.  COUNT() o COUNT() counts the number of rows in the set.  MIN() o MIN() finds the minimum value in the set.  MAX() o MAX() finds the maximum value in the set.  SUM() o SUM() sums all the values in the set.  AVG() o AVG() computes the arithmetic mean of all the values in the set.  GROUP BY o The GROUP BYclause consists of the GROUP BY keyword and one or more columns. Each simple or composite value of the column(s) becomes a group. The query computes the aggregate function separately, and returns one row, for each group.  HAVING o The HAVING clause is used with the GROUP BY clause to filter group results. SELECT column_name FROM table_name WHERE condition GROUP BY column_name HAVING condition ORDER BY column_name; 3.4 Join queriesjoin / left table / right table o A join is a SELECT statement that combines data from two tables , known as the left table and right table, into a single result. o The tables are combined by comparing columns from the left and right tables, usually with the = operator.  AS o To simplify queries or result tables, a column name can be replaced with an alias. The alias follows the column name, separated by an optional AS keyword. o e.g. SELECT some_long_column_name AS short_name

INNER JOIN clause o A join clause determines how a join query handles unmatched rows. Two common join clauses are: o INNER JOIN  INNER JOIN selects only matching left and right table rows.  INNER is optional. SELECT column_name AS group, column_name2 AS supervisor FROM table1 t JOIN table2 t ON t1.ID = t2.ID; -- only matching TRUE rows will be joined.  FULL JOIN o FULL JOIN selects all left and right table rows, regardless of match. SELECT column_name AS group, column_name2 AS supervisor FROM table1 t FULL JOIN table2 t ON t1.ID = t2.ID; -- all rows from both tables will be joined.  LEFT JOIN o LEFT JOIN selects all left table rows , but only matching right table rows. SELECT column_name AS group, column_name2 AS supervisor FROM table1 t LEFT JOIN table2 t ON t1.ID = t2.ID; -- all rows from t1 will be joined with matching rows from t2.  RIGHT JOIN o RIGHT JOIN selects all right table rows , but only matching left table rows. o right join can be confusing, most avoid it's usage. You can switch the table order to LEFT JOIN the table of your choose. SELECT column_name AS group, column_name2 AS supervisor