2. Query
A query is a statement requesting the retrieval of information. The
portion of a DML that involves information retrieval is called a
query language.
There are a number of database query languages in use, either
commercially or experimentally. We study the most widely used
query language SQL.
2
3. Introduction
A database system provides a data-definition language to
specify the database schema and a data-manipulation language
to express database queries.
In practice, the data-definition and data-manipulation languages
are not two separate languages; instead they simply form parts
of a single database language, such as the widely used SQL
language.
SQL is abbreviation for Structured Query Language
โข A Database Language that communicates with
Relational Database(stores and provides access to data points that
are related to one another)
โข โข Can be divided into more specific language
โข โ DDL
โข โ DML
โข โ DCL
โข โ TCL
7/17/2023
Database
3
4. DDL
โข โข DDL is abbreviation for Data Definition Language
โข โข Used to define the database structure or schema
โข โข CREATE - to create objects in the database
โข โข ALTER - alters the structure of the database
โข โข DROP - delete objects from the database
โข โข TRUNCATE - remove all records from a table
โข โข COMMENT - add comments to the data dictionary
โข โข RENAME - rename an object
7/17/2023
Database
4
5. DML
DML is abbreviation for Data Manipulation Language
โข Used to manipulate data within schema objects
Enables users to access or manipulate data as organized by the
appropriate data model.
The types of access are:
โข Retrieval of information stored in the database
โข Insertion of new information into the database
โข Deletion of information from the database
โข Modification of information stored in the database
โข SELECT - retrieve data from the a database
โข INSERT - insert data into a table
โข UPDATE - updates existing data within a table
โข DELETE - deletes all records from a table, the space for the
records remain
โข MERGE - UPSERT operation (Insert or Update)
โข CALL - call a Stored-Procedure
7/17/2023
Database
5
6. DCL
โข DCL is abbreviation for Data Control Language
โข Used to define roles and permissions to access database
โข GRANT - gives user's access privileges to database
โข REVOKE - withdraw access privileges given with the
GRANT command
7. TCL
TCL is abbreviation for Transactional Control Language
โข Used to manage the changes made by DML statements
โข COMMIT - save work done
โข ROLLBACK - restore database to original since the last
COMMIT
8. Database Design
Database systems are designed to manage large bodies of
information. These large bodies of information do not exist in
isolation. They are part of the operation of some enterprise
whose end product may be information from the database or
may be some device or service for which the database plays
only a supporting role.
Database design mainly involves the design of the database
schema.
9. Example : Database Design for a University
Organization
The university is organized into departments. Each department is
identified by a unique name (dept name), is located in a
particular building, and has a budget.
โข Each department has a list of courses it offers. Each course has
associated with it a course id, title, dept name, and credits, and
may also have have associated prerequisites.
โข Instructors are identified by their unique ID. Each instructor
has name, associated department (dept name), and salary.
โข Students are identified by their unique ID. Each student has a
name, an associated major department (dept name), and tot cred
(total credit hours the student earned thus far)
9
10. โข The university maintains a list of classrooms, specifying
the name of the building, room number, and room
capacity.
โข The university maintains a list of all classes (sections)
taught. Each section is identified by a course id, sec id,
year, and semester, and has associated with it a semester,
year, building, room number, and time slot id (the time
slot when the class meets).
โข The department has a list of teaching assignments
specifying, for each instructor, the sections the instructor is
teaching.
โข The university has a list of all student course registrations,
specifying, for each student, the courses and the associated
sections that the student has taken (registered for). 10