Lecture Notes 1.0 Introduction To Databases
Lecture Notes 1.0 Introduction To Databases
• Examples
MySQL, PostgreSQL, Microsoft Access, SQL Server, Oracle etc.
Data Definition Language (DDL)
Data Definition Language (DDL) or Schema Definition Language statements are used to
define the database structure or schema.
• CREATE - create an object in the database
• ALTER - alter the structure of an object in the database
• DROP - destroy an object from the database
• TRUNCATE - remove all records from a table; the space allocated for the records is also
released
• COMMENT - add comments to the data dictionary
• RENAME - rename an object in the database
Data Manipulation Language (DML)
Data Manipulation Language (DML) statements are used for managing data within schema
objects.
• INSERT - insert data into a table
• UPDATE - update existing data in a table
• DELETE - delete record(s) from a table, the space for the records remains there.
• MERGE - UPSERT operation (insert or update)
• CALL - call a SQL or Java subprogram
• EXPLAIN PLAN - explain access path to Data
• LOCK TABLE - control concurrency
Data Retrieval Language / Data Query
Language (DRL/DQL)
• SELECT - retrieve data from the a database
Data Control Language (DCL)
Data Control Language (DCL) statements. Some examples:
• GRANT - gives user's access privileges to database
• REVOKE - withdraw access privileges given with the GRANT command
Transaction Control (TCL)
Transaction Control (TCL) statements are used to manage the changes made by
DML statements. It allows statements to be grouped together into logical
transactions.
• COMMIT - save work done
• SAVEPOINT - identify a point in a transaction to which you can later roll Back
• ROLLBACK - restore database to original since the last COMMIT
• SET TRANSACTION - Change transaction options like isolation level and
what rollback segment to use
Database Applications
• Where we use database?
• Answer is everywhere.
• Banking
• Airlines
• Sales
• Universities
• Manufacturing
• Web-based services
Search query
Search place
Traditional File-Based Systems
• A collection of application programs that perform services for the end-users such as the production
of reports. Each program defines and manages its own data.
Limitations of file-based system
Database
Management
System
Individual
Student
Schedules
Student
Scheduling
Class
Student Data DBMS Lists
Class Data
Faculty Data
Enroll Data
Faculty Final
Scheduling Faculty
Schedules
Paychecks &
Paystubs
Payroll
Payroll
Report
Interactive
Users
Advantages of database
• Data sharing
• Controlled redundancy
• Data consistency
• Data independence
• Improved data integrity
• Data dictionary – Meta data
• Better data accessibility
Disadvantages of Databases
• Complexity
• Higher hardware costs
• Higher programming costs
• High conversion costs
• Increased vulnerability
• More difficult recovery
Components of the DBMS Environment
• Hardware
• Software
• Data
• People
Database Users