Beruflich Dokumente
Kultur Dokumente
Data Integrity
Entity integrity: It specifies that there should be no duplicate rows in a table.
Domain integrity: It enforces valid entries for a given column by restricting the type,
the format, or the range of values.
Referential integrity: It specifies that rows cannot be deleted, which are used by other
records.
User-defined integrity: It enforces some specific business rules that are defined by
users. These rules are different from entity, domain or referential integrity.
SQL session
A SQL session is an occurrence of a user interacting with a relational database through the use of
SQL commands. When a user initially connects to the database, a session is established
When a user connects to a database, the SQL session is initialized. The CONNECT command is used
to establish a database connection.
CONNECT user@database
When a user disconnects from a database, the SQL session is terminated. The DISCONNECT
command is used to disconnect a user from the database.
Basic categories of commands used in SQL to perform various functions. These functions include
building database objects, manipulating objects
CREATE TABLE
ALTER TABLE
DROP TABLE
CREATE INDEX
ALTER INDEX
DROP INDEX
CREATE VIEW
DROP VIEW
Data Manipulation Language (DML)
Data Manipulation Language (DML) is the part of SQL used to manipulate data within objects
of a relational database.
INSERT
UPDATE
DELETE
Data Query Language (DQL) is the most concentrated focus of SQL for modern relational
database users. The base command is as follows:
SELECT
Data control commands in SQL allow you to control access to data within the database.
These Data Control Language (DCL) commands are normally used to create objects related
to user access and also control the distribution of privileges among user
ALTER PASSWORD
GRANT REVOKE
CREATE SYNONYM
commands are normally used to create objects related to user access and also control the
distribution of privileges among users
Data administration commands allow the user to perform audits and perform analyses on
operations within the database. They can also be used to help analyse system performance
START AUDIT
STOP AUDIT
In addition to the previously introduced categories of commands, there are commands that
allow the user to manage database transactions
A database object is any defined object in a database that is used to store or reference data.
Some examples of database objects include tables, views, clusters, sequences, indexes, and
synonyms.
Dropping Tables
Integrity constraints
Integrity constraints are used to ensure accuracy and consistency of data in a relational
database. Data integrity is handled in a relational database through the concept of
referential integrity. Many types of integrity constraints play a role in referential integrity
(RI).
Primary key is the term used to identify one or more columns in a table that make a row of
data unique
Unique Constraints
A unique column constraint in a table is similar to a primary key in that the value in that
column for every row of data in the table must have a unique value
A foreign key is a column in a child table that references a primary key in the parent table. A
foreign key constraint is the main mechanism used to enforce referential
Previous examples use the keywords NULL and NOT NULL listed on the same line as each
column and after the data type. NOT NULL is a constraint that you can place on a table’s
column
Check Constraints
Check (CHK) constraints can be utilized to check the validity of data entered into particular
table columns. Check constraints are used to provide back-end database edit
although edits are commonly found in the front-end application as well. General edits
restrict values that can be entered into columns or objects, whether within the database
itself or on a front-end application. The check constraint is a way of providing another
protective layer for the data.
Dropping Constraints
Any constraint that you have defined can be dropped using the ALTER TABLE command with
the DROP CONSTRAINT option.
ALTER TABLE EMPLOYEES DROP CONSTRAINT EMPLOYEES_PK;
Normalization
it does not contain any composite or multi-valued attribute. A relation is in first normal
form if every attribute in that relation is singled valued attribute.
Relation must be in first normal form and relation must not contain any partial
dependency. A relation is in 2NF if it has No Partial Dependency, i.e., no non-prime
attribute (attributes which are not part of any candidate key) is dependent on any
proper subset of any candidate key of the table.
The third normal form’s objective is to remove data in a table that is not dependent on the
primary key
Denormalization
transaction
A transaction is a unit of work that is performed against a database. Transactions are units or
sequences of work accomplished in a logical order, whether in a manual fashion by a user or
automatically by some sort of a database program
COMMIT
ROLLBACK
SAVEPOINT
A savepoint is a point in a transaction where you can roll the transaction back to this point
without rolling back the entire transaction
savepoint savepoint_name
A query is an inquiry into the database using the SELECT statement. A query is used to
extract data from the database in a readable format according to the user’s request
IN
The IN operator is used to compare a value to a list of literal values that have been specified.
For TRUE to be returned, the compared value must match at least one of the values in the
list.
The IN operator is used to compare a value to a list of literal values that have been specified.
For TRUE to be returned, the compared value must match at least one of the values in the
list
Using the IN operator can achieve the same results as using the OR operator and can return
the results more quickly
LIKE
EXISTS
The EXISTS operator is used to search for the presence of a row in a specified table that
meets certain criteria
Aggregate functions.
The DISTINCT command cannot be used with COUNT(*), only with COUNT
(column_name)
The value of an argument must be numeric to use the SUM function. The SUM function
cannot be used on columns having a data type other than numeric, such as
character or date
The GROUP BY clause
The GROUP BY clause is used in collaboration with the SELECT statement to arrange
identical data into groups. The GROUP BY clause follows the WHERE clause in a
SELECT statement and precedes the ORDER BY clause.
WHERE clause and must precede the ORDER BY clause if one is used.