Unit 8.3 Database Management Systems & SQL (DDL &DML)
Know what is meant by the term Database Management Systems (DBMS) and the tools that are commonly included.
Know what is meant by the term Structured Query Language (SQL) and why it is used.
Be able to use Data Definition Language (DDL) to create and modify database objects.
Be able to use Data Manipulation Language (DML) to add, retrieve and update data in a database.
Software that provides user with an Interface for managing database.
Allows user to interact with databases with tools to create/retrieve/update/delete and other admin tasks.
Terms | Explanation |
Integrity | Database structure can change but the applications using data can stay the same. |
Efficiency | Avoids data duplication & inconsistency, less storage space taken up as data is shared. |
Consistency | Data is the same regardless of who or when its being viewed |
Automatic Backups | Can be configured to automatically backup to local and remote storage while preserving integrity. |
Security | In one central secure place. |
Access Rights for Users/Groups | Users can be given varying access levels including what data they can access/read/write/execute/delete/append access. |
Customization | Applications can be stored to suit users needs. |
Data Modelling | Can do Customisation and Access rights. DBMS often consists of forms & reports. Most importantly separating applications from data. When application is used only data needed is called upon as not all data is needed every time so database with DBMS can be viewed by many with different responsibilities |
Industry standard programming language that allows manages and interacts with databases.
Two subsets - Data Definition Language (DDL) and Data Manipulation Language (DML)
DDL creates & modifies database objects whereas DML adds/retrieves/updates data in database.
Different data types assigned to fields in SQL, DDL & DML
Type | Explanation |
CHARACTER(n) | Stores specific character number, needs to be stated when table set up. |
VARCHAR(n) | Stores variable character number, needs to be stated when table set up. |
BOOLEAN | Stores Boolean values, True or False. |
INTEGER | Stores whole numbers (integers) without decimal places. |
REAL | Stores numbers with decimal places. |
DATE | Stores date value without time component |
TIME | Stores time value without data component |
Must use speech marks around string values that are textual data e.g. “Robert” but not to be used around numbers or Boolean.
Brackets are used when calling a function with arguments (data) e.g. using SUM(LENGTH)
Also when providing multiple values e.g. INSERT INTO Customers (FirstName, LastName)
Also grouping conditions together e.g. SELECT * FROM employees WHERE (Salary>10000 AND departmentID=2) OR (salary<30000 AND departmentID=3)
Creates and modifies Database objects
Memorize ones with red box as they are syntax’s for exam!!! blue boxes are examples
Modify structure of database object use ALTER
Adds, retrieves and updates etc. data in a database
Memorize Red boxes for Syntax!! blue boxes are examples.
SELECT retrieves data but you need to specify which fields
FROM specifies table name you want the data from
WHERE finds date that meets a specified condition.
ORDER BY sorts results from 1+ fields - ASCENDING (ASC) or DESCENDING (DESC)
GROUP BY groups rows that have the same values together
INNER JOIN combines rows from 2+ tables that have related column such as Foreign Key, if selecting data from multiple tables you must state table name for each field.
Below only shows SQL Comment and isn’t needed in SQL Code
On section is where two common fields are mentioned (The PK&FK relationship)
AVG finds average
SUM finds sum of values in a column
COUNT will count number of rows in a table
INSERT INTO inserts new information into table - All punctuation is important!! if information is a string use ‘’ if integer no ‘ needed
UPDATE will update data in the table
DELETE FROM will delete data from tables
LIKE is a SQL clause - find information that begins with a certain character dont forget format LIKE ‘?%’
AND is a SQL clause, use it to set up multiple conditions
OR is a SQL clause, use it set different conditions i.e. retrieve information if field name begins with letter A or B
% wildcard - represents one or more string characters, e.g. LIKE ‘A%’ would ask system to find data in any field beginning with A.
Know what is meant by the term Database Management Systems (DBMS) and the tools that are commonly included.
Know what is meant by the term Structured Query Language (SQL) and why it is used.
Be able to use Data Definition Language (DDL) to create and modify database objects.
Be able to use Data Manipulation Language (DML) to add, retrieve and update data in a database.
Software that provides user with an Interface for managing database.
Allows user to interact with databases with tools to create/retrieve/update/delete and other admin tasks.
Terms | Explanation |
Integrity | Database structure can change but the applications using data can stay the same. |
Efficiency | Avoids data duplication & inconsistency, less storage space taken up as data is shared. |
Consistency | Data is the same regardless of who or when its being viewed |
Automatic Backups | Can be configured to automatically backup to local and remote storage while preserving integrity. |
Security | In one central secure place. |
Access Rights for Users/Groups | Users can be given varying access levels including what data they can access/read/write/execute/delete/append access. |
Customization | Applications can be stored to suit users needs. |
Data Modelling | Can do Customisation and Access rights. DBMS often consists of forms & reports. Most importantly separating applications from data. When application is used only data needed is called upon as not all data is needed every time so database with DBMS can be viewed by many with different responsibilities |
Industry standard programming language that allows manages and interacts with databases.
Two subsets - Data Definition Language (DDL) and Data Manipulation Language (DML)
DDL creates & modifies database objects whereas DML adds/retrieves/updates data in database.
Different data types assigned to fields in SQL, DDL & DML
Type | Explanation |
CHARACTER(n) | Stores specific character number, needs to be stated when table set up. |
VARCHAR(n) | Stores variable character number, needs to be stated when table set up. |
BOOLEAN | Stores Boolean values, True or False. |
INTEGER | Stores whole numbers (integers) without decimal places. |
REAL | Stores numbers with decimal places. |
DATE | Stores date value without time component |
TIME | Stores time value without data component |
Must use speech marks around string values that are textual data e.g. “Robert” but not to be used around numbers or Boolean.
Brackets are used when calling a function with arguments (data) e.g. using SUM(LENGTH)
Also when providing multiple values e.g. INSERT INTO Customers (FirstName, LastName)
Also grouping conditions together e.g. SELECT * FROM employees WHERE (Salary>10000 AND departmentID=2) OR (salary<30000 AND departmentID=3)
Creates and modifies Database objects
Memorize ones with red box as they are syntax’s for exam!!! blue boxes are examples
Modify structure of database object use ALTER
Adds, retrieves and updates etc. data in a database
Memorize Red boxes for Syntax!! blue boxes are examples.
SELECT retrieves data but you need to specify which fields
FROM specifies table name you want the data from
WHERE finds date that meets a specified condition.
ORDER BY sorts results from 1+ fields - ASCENDING (ASC) or DESCENDING (DESC)
GROUP BY groups rows that have the same values together
INNER JOIN combines rows from 2+ tables that have related column such as Foreign Key, if selecting data from multiple tables you must state table name for each field.
Below only shows SQL Comment and isn’t needed in SQL Code
On section is where two common fields are mentioned (The PK&FK relationship)
AVG finds average
SUM finds sum of values in a column
COUNT will count number of rows in a table
INSERT INTO inserts new information into table - All punctuation is important!! if information is a string use ‘’ if integer no ‘ needed
UPDATE will update data in the table
DELETE FROM will delete data from tables
LIKE is a SQL clause - find information that begins with a certain character dont forget format LIKE ‘?%’
AND is a SQL clause, use it to set up multiple conditions
OR is a SQL clause, use it set different conditions i.e. retrieve information if field name begins with letter A or B
% wildcard - represents one or more string characters, e.g. LIKE ‘A%’ would ask system to find data in any field beginning with A.