SE223
LECTURE 2
DATABASE LANGUAGE
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
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
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
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
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
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
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.
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
• 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
11
Thanks
7/17/2023
Database
12

Lecture 2 DATABASE LANGUAGE.pptx

  • 1.
  • 2.
    Query A query isa 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 systemprovides 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 • • DDLis 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 abbreviationfor 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 isabbreviation 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 abbreviationfor 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 systemsare 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 : DatabaseDesign 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 universitymaintains 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
  • 11.
  • 12.