DBMS NOTES (Module4)
DBMS NOTES (Module4)
What is a database?
Types of Databases
There are various types of databases used for storing different varieties of data:
1) Centralized Database
It has decreased the risk of data management, i.e., manipulation of data will
not affect the core data.
Data consistency is maintained as it manages data in a central repository.
It provides better data quality, which enables organizations to establish data
standards.
It is less costly because fewer vendors are required to handle the data sets.
The size of the centralized database is large, which increases the response
time for fetching the data.
It is not easy to update such an extensive database system.
If any server failure occurs, entire data will be lost, which could be a huge
loss.
2) Distributed Database
3) Relational Database
This database is based on the relational data model, which stores data
in the form of rows(tuple) and columns(attributes), and together forms
a table(relation).
A relational database uses SQL for storing, manipulating, as well as
maintaining the data. E.F. Codd invented the database in 1970.
Each table in the database carries a key that makes the data unique
from others. Examples of Relational databases are MySQL, Microsoft
SQL Server, Oracle, etc.
4) NoSQL Database
5) Cloud Database
There are numerous cloud platforms, but the best options are:
6) Object-oriented Databases
The type of database that uses the object-based data model approach
for storing data in the database system.
The data is represented and stored as objects which are similar to the
objects used in the object-oriented programming language.
7) Hierarchical Databases
8) Network Databases
9) Personal Database
Collecting and storing data on the user's system defines a Personal Database.
This database is basically designed for a single user.
The type of database which creates and updates the database in real-
time. It is basically designed for executing and handling the daily data
operations in several businesses.
For example, An organization uses operational databases for
managing per day transactions.
FIELDS:
Fields are the components that provide structure for a table. fields
defined but no rows (records). In databases, fields are used to maintain
relationships between tables.
Records:
Table:
Tables are database objects that contain all the data in a database. In
tables, data is logically organized in a row-and-column format similar to a
spreadsheet. Each row represents a unique record, and each column represents a
field in the record
DATABASE USERS:
End Users
End users are the people whose jobs require access to a database for
querying, updating and generating reports.
Application user
Sophisticated user
Sophisticated users are those who have their own way of accessing the
database.
This means they do not use the application program provided in the
system. Instead, they might define their own application or describe
their need directly by using query languages.
Application Programmers
INSTANCE OF DATABASE.
Schema
A database schema is a structure that represents the logical storage of
the data in a database. It represents the organization of data and provides
information about the relationshipsbetween the tables in a given database
Data
Data is the raw material that can be processed for any computing machine.
For example − Employee name, Product name, Name of the student, Marks of the
student, Mobile number, Image etc.
Objectives of DBMS
1. To Reduce Duplication
2.To Share the Data : To share the data to its users under the controlled
environment is the objective of DBMS.
For example, we all use Google Drive. Actually, it has been renamed of
Google's old Google Docs.google docs application is also DBMS.
Integrity of data means to bring the accuracy and consistency. For this,
DBMS gives power toits user that they can establish the validation controls.
4. To Secure the Data :Data of any organisation is the worthy asset. It should be
protected. For security of the data is the responsibility of data administrator.
Data Model
Data Model gives us an idea that how the final system will look like after its
complete implementation
1. Hierarchical Model
2. Network Model
3. Entity-Relationship Model
4. Relational Model
5. Object-Oriented Data Model
Hierarchical Model
Hierarchical Model was the first DBMS model. This model
organises the data in the hierarchical tree structure.
The hierarchy starts from the root which has root data and then
it expands in the form of a tree adding child node to the parent
node.
One-to-many relationship:
Parent-Child Relationship
Deletion Problem:
Pointers:
Network Model
This model is the same as the hierarchical model, the only difference
is that a record can have more than one parent
As more and more relationships need to be handled the system might get Complex.
Entity-Relationship Model
Relational Model
Relational Model is the most widely used model. In this model, the data is
maintained in the form of a two-dimensional table. All the information is stored in
the form of row and columns.
The real-world problems are more closely represented through the object-
oriented data model. In this model, both the data and relationship are present in a
single structure known as an object.
Database views:
User programmers:
Physical Level
This is the lowest level in the three level architecture. It is also known as the
internal level. The physical level describes how data is actually stored in the
database.
Conceptual Level
The conceptual level is at a higher level than the physical level. It is also
known asthe logical level.
It describes how the database appears to the users conceptually and the
relationships between various data tables.
External Level:
This is the highest level in the three level architecture and closest to the user.
It is also known as the view level.
The external level only shows the relevant database content to the users in
the form of views and hides the rest of the data
Direct file organization— organization of files based on a unique for each file,
which is accessed directly through the memory address of the key. Direct file
organization allows data to be retrieved quickly in a random manner.
Components of DBMS:
Data Mining
Data warehouse
Data Mart:
data mart are smaller than data warehouses and generally contain
information from single department of a business or organization.It can be
regarded subset of data warehouse.
Formatting Columns
Through the SQL*Plus COLUMN command, you can change the column headings
and reformat the column data in your query results.
When displaying column headings, you can either use the default heading or you
can change it using the COLUMN command. The sections below describe how the
default headings are derived and how you can alter them with the COLUMN
command.
Default Headings
SQL*Plus uses column or expression names as default column headings when
displaying query results. Column names are often short and cryptic, however, and
expressions can be hard to understand.
Introduction to SQL
What is SQL?
Numeric data types such as: INT , TINYINT , BIGINT , FLOAT , REAL
Date and Time data types such as: DATE , TIME , DATETIME , etc.
Character and String data types such as: CHAR , VARCHAR , TEXT , etc.
Unicode character string data types such as: NCHAR , NVARCHAR ,
NTEXT , etc.
SQL Languages
SQL Languages are those languages that allow the database users to read,
modify, delete and store data in the database systems.
Following are the four different types of languages or commands which are widely
used in SQL queries:
The DDL Languages or commands are categorized into five commands which are
widely used in the SQL queries:
CREATE Command
This DDL command allows us to create the new table, function, stored
procedure, and other database objects.
ALTER Command
This DDL command allows us to modify the structure of database objects.
TRUNCATE Command
This DDL command allows the database users to remove all the existing
records from the table.
1. TRUNCATE TABLE Name_of_Table;
RENAME Command
This DDL command allows the users to change the name of the existing table.
1. RENAME Mobile_Details TO Mobile_Records;
We can use this type of language when we want to access the record, insert the
new record, update the record, and delete the existing values from the tables.
Following are the four DML Languages or commands used in the SQL queries:
SELECT Command
This DML command allows us to access the stored records from the tables. We can
also use the condition in the SELECT command for accessing the particular rows.
Syntax of SELECT Command:
1. SELECT * FROM Name_of_Table;
INSERT Command
This DML command allows the database users to insert the new record or
rows in the tables.
Syntax of INSERT Command for inserting the single record:
1. INSERT INTO Name_of_Table ( Column_1, Column_2, Column_3, …..) V
ALUES (Value1_of_Column
UPDATE Command
This DML command allows the database users to change the existing record
or rows in the tables.
DELETE Command
This DML command allows the database users to delete a particular record
or row from the tables.
Data Control Languages allow DBA to manage the rights and permissions
on the data in the database.
Following are the two DCL Languages or commands used in the SQL queries:
Let's discuss the above two DCL commands one by one with syntax and examples.
GRANT Command
This DCL command allows the database administrator to give permissions to the
user for retrieving the data.
Syntax of Grant DCL Command:
1. GRANT Name_of_Privilege ON Object TO User;
REVOKE Command
This DCL command allows the database administrator to remove all the
permissions applied by the GRANT DCL command.
Let's discuss the above TCL commands one by one with syntax and examples.
COMMIT Command
This command allows the database users to save the operations in the
database.
Syntax of Commit command:
1. COMMIT;
Rollback Command
This command allows the database users to restore the transactions to that
state which was last committed.
1. ROLLBACK;
Trigger:
sorted records, or in operations like joins will be more efficient in sorted records.
All the records are by default sorted based on the primary key column. In addition,
we can specify to sort the records based on other columns, as required.What is a
Database Search?
To put titles at the top and bottom of each page of a report, enter
SQL> /
SQL*Plus displays the following output:
COMPANY CONFIDENTIAL
Entity Relationship :
*************************************************************
DATABASE MANAGEMENT SYSTEMS Page 26