DATABASE
MANAGEMENT
OBJECTIVES
By the end of the lesson students should be able to:
Define the terms Database, DBMS, SQL, stored procedure, Query
strings, Database Connections and Web services
State some commonly used Enterprise level DBMS’s
Explain a Select SQL statement and give examples
Explain an Insert SQL statement and give examples
Explain an Inner Join SQL statement and give examples
Explain a Update SQL statement and give examples
Explain a Delete SQL statement and give examples
COMMON TERMS
Database: A database is an organized collection of
structured information, or data, typically stored
electronically in a computer system.
DBMS: Database Management Systems are software
systems used to store, retrieve, and run queries on data.
A DBMS serves as an interface between an end-user and
a database, allowing users to create, read, update, and
delete data in the database.
SQL: Structured Query Language (SQL) is a standardized
programming language that is used to manage
relational databases and perform various operations on
the data in them.
COMMON TERMS
Stored procedure: A stored procedure is a set of SQL statements
with an assigned name, which are stored in a relational database
management system as a group, so it can be reused and shared by
multiple programs.
Query strings: A query string is a set of characters input to a
computer or Web browser and sent to a query program to recover
specific information from a database .
COMMON TERMS
Database Connection: A Database Connection object provides a
convenient way of storing the connection details of a live database.
Web services: Web services are XML-based information exchange
systems that use the Internet for direct application-to-application
interaction. A web service is a collection of open protocols and
standards used for exchanging data between applications or
systems.
STRUCTURED QUERY
LANGUAGE (SQL)
SQL is used for the following:
Modifying database table and index structures;
Adding, updating and deleting rows of data; and
Retrieving subsets of information from within relational database
management systems.
ENTERPRISE LEVEL DBMS’S
Oracle Database 18c
Microsoft SQL Server
IBM DB2
SAP Sybase ASE
PostgreSQL
MariaDB Enterprise etc
SQL SELECT STATEMENT
The SELECT statement is used to select data from a database. The
data returned is stored in a result table, called the result-set.
Examples
1. SELECT column1, column2, ...
FROM table_name;
2. SELECT * FROM table_name;
3. SELECT * FROM table_name WHERE criteria;
4. SELECT column1, column2, ... FROM table_name WHERE
criteria;
[Link]
SQL INSERT STATEMENT
The INSERT INTO statement is used to insert new records in a table.
Examples
1. INSERT INTO table_name (column1, column2, column3, ...
)
VALUES (value1, value2, value3, ...);
2. INSERT INTO table_name
VALUES (value1, value2, value3, ...);
[Link]
INSERTING MULTIPLE
RECORDS
INSERT INTO table_name (column_list)
VALUES
(value_list_1),
(value_list_2),
...
(value_list_n);
Note that this syntax does not work for some databases.
SQL INNER-JOIN STATEMENT
The INNER JOIN keyword selects records that have matching values
in both tables.
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
[Link]
SQL UPDATE STATEMENT
The UPDATE statement is used to modify the existing records in a table.
When updating records in a table! Notice the WHERE clause in the
UPDATE statement. The WHERE clause specifies which record(s) that
should be updated. If you omit the WHERE clause, all records in the table
will be updated!
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
UPDATE Customers
SET ContactName = 'Alfred Schmidt', City= 'Frankfurt'
WHERE CustomerID = 1;
[Link]
SQL DELETE STATEMENT
The DELETE statement is used to delete existing records in a table.
DELETE FROM table_name WHERE condition;
DELETE FROM Customers WHERE CustomerName='Alfreds
Futterkiste’;
[Link]