DBMS Unit - I
DBMS Unit - I
com (F&CA)
DATABASE MANAGEMENT SYSTEM (DBMS)
UNIT I
Introduction to Databases:
Definition:
A database is a collection of organized data that can be easily accessed,
managed, and updated. It can store data in tables, documents, or other formats
depending on the database system used.
Database Management System (DBMS):
Definition:
A DBMS is software that facilitates the creation, manipulation, and
administration of databases. It acts as an intermediary between users and the database.
Functions:
Includes data storage, retrieval, security, and backup. Examples include
MySQL, PostgreSQL, Oracle, and MongoDB.
Database Operations:
CRUD Operations: Basic operations performed on data, including Create, Read,
Update, and Delete.
Queries: Requests for specific data using query languages like SQL (Structured
Query Language). SQL allows for complex queries and data manipulation.
Database Languages
Data Definition Language
Data Manipulation Language
Data Control Language
Transactional Control Language
Data Definition Language (DDL)
DDL is the short name for Data Definition Language, which deals with database schemas and
descriptions, of how the data should reside in the database.
CREATE: to create a database and its objects like (table, index, views, store
procedure, function, and triggers)
ALTER: alters the structure of the existing database
DROP: delete objects from the database
TRUNCATE: remove all records from a table, including all spaces allocated for the
records are removed
COMMENT: add comments to the data dictionary
RENAME: rename an object
Data Manipulation Language (DML)
DML is the short name for Data Manipulation Language which deals with data manipulation
and includes most common SQL statements such SELECT, INSERT, UPDATE, DELETE,
etc., and it is used to store, modify, retrieve, delete and update data in a database. Data query
language (DQL) is the subset of “Data Manipulation Language”. The most common
command of DQL is SELECT statement. SELECT statement help on retrieving the data
from the table without changing anything in the table.
SELECT: retrieve data from a database
INSERT: insert data into a table
UPDATE: updates existing data within a table
DELETE: Delete all records from a database table
MERGE: UPSERT operation (insert or update)
CALL: call a PL/SQL or Java subprogram
EXPLAIN PLAN: interpretation of the data access path
LOCK TABLE: concurrency Control
Data Control Language (DCL)
DCL is short for Data Control Language which acts as an access specifier to the database.
(Basically, to grant and revoke permissions to users in the database
GRANT: grant permissions to the user for running DML (SELECT, INSERT,
DELETE,) commands on the table
REVOKE: revoke permissions to the user for running DML (SELECT, INSERT,
DELETE,) command on the specified table
Transactional Control Language (TCL)
TCL is short for Transactional Control Language which acts as an manager for all types of
transactional data and all transactions. Some of the commands of TCL are
Roll Back: Used to cancel or Undo changes made in the database
Commit: It is used to apply or save changes in the database
Save Point: It is used to save the data on the temporary basis in the database
Data Query Language (DQL)
Data query language(DQL) is the subset of “Data Manipulation Language”. The most
common command of DQL is 1the SELECT statement. SELECT statement helps us in
retrieving the data from the table without changing anything or modifying the table. DQL is
very important for retrieval of essential data from a database.
Architecture of DBMS
1. Query Processor:
It interprets the requests (queries) received from end user via an application program into
instructions. It also executes the user request which is received from the DML compiler.
Query Processor contains the following components –
DML Compiler: It processes the DML statements into low level instruction (machine
language), so that they can be executed.
DDL Interpreter: It processes the DDL statements into a set of table containing meta
data (data about data).
Embedded DML Pre-compiler: It processes DML statements embedded in an
application program into procedural calls.
Query Optimizer: It executes the instruction generated by DML Compiler.
2. Storage Manager:
Storage Manager is a program that provides an interface between the data stored in the
database and the queries received. It is also known as Database Control System. It maintains
the consistency and integrity of the database by applying the constraints and executing
the DCL statements. It is responsible for updating, storing, deleting, and retrieving data in the
database.
It contains the following components –
Authorization Manager: It ensures role-based access control, i.e,. checks whether the
particular person is privileged to perform the requested operation or not.
Integrity Manager: It checks the integrity constraints when the database is modified.
File Manager: It manages the file space and the data structure used to represent
information in the database.
Buffer Manager: It is responsible for cache memory and the transfer of data between
the secondary storage and main memory.
3. Disk Storage:
It contains the following components:
Data Files: It stores the data.
Data Dictionary: It contains the information about the structure of any database
object. It is the repository of information that governs the metadata.
Indices: It provides faster retrieval of data item.
Data Models:
A Data Model in Database Management System (DBMS) is the concept of tools that are
developed to summarize the description of the database. Data Models provide us with a
transparent picture of data which helps us in creating an actual database. It shows us from the
design of the data to its proper implementation of data.
Types of Relational Models
1. Conceptual Data Model
2. Representational Data Model
3. Physical Data Model
It is basically classified into 3 types:-
Components of ER Diagram
ER Model consists of Entities, Attributes, and Relationships among Entities in a Database
System.
What is Linux?
Open Source: Linux is released under the GNU General Public License (GPL),
allowing users to view, modify, and distribute the source code.
Unix-like: It follows many of the design principles of Unix, providing a multi-user,
multitasking environment.
2. Components of Linux
Kernel: The core part of the operating system that manages hardware, system
resources, and communication between software and hardware.
Shell: The command-line interface through which users interact with the operating
system. Popular shells include Bash, Zsh, and Fish.
File System: Linux uses a hierarchical file system structure, with directories like
/home, /etc, and /usr.
Utilities: A collection of command-line tools and applications that perform various
functions (e.g., file manipulation, system monitoring).
3. Distributions
Linux comes in many distributions (distros) tailored for various needs. Some popular ones
include:
Ubuntu: User-friendly and ideal for beginners.
Fedora: Cutting-edge features and innovations.
CentOS/RHEL: Stable and widely used in enterprise environments.
Arch Linux: Rolling release model for advanced users who want to customize their
system.
4. Key Features
Security: Built-in security features, like user permissions and access controls,
enhance system security.
Stability and Performance: Known for its reliability and efficient resource
management.
Customization: Users can tailor almost every aspect of their environment, from the
desktop environment to system processes.
Community Support: A vast community provides documentation, forums, and
resources for troubleshooting and learning.
Properties of Linux
1. Open Source
Transparency: The source code is available for anyone to view, modify, and distribute.
Community Collaboration: Contributions from a global community enhance its
development and security.
2. Multitasking
Concurrent Processes: Linux can run multiple processes simultaneously, allowing for
efficient resource utilization.
3. Multiuser Capability
User Management: Multiple users can log in and use the system at the same time,
each with their own settings and permissions.
4. Portability
Cross-Platform: Linux can run on various hardware architectures, from servers to
embedded systems, making it versatile.
5. Security
Permissions and Access Control: Strong user permissions prevent unauthorized access
to files and processes.
Regular Updates: Active community and developers regularly patch vulnerabilities.
6. Stability and Reliability
Uptime: Linux systems are known for their stability, often running for extended
periods without needing a reboot.
Error Handling: Robust error management prevents crashes and system failures.
7. Customizability
Flexible Configuration: Users can customize nearly every aspect of their environment,
from the kernel to the desktop interface.
Variety of Distributions: Different Linux distributions cater to various user needs,
from beginner-friendly to highly specialized.
8. Efficient Performance
Resource Management: Linux uses system resources effectively, making it suitable
for both low-end hardware and high-performance servers.
9. Rich Networking Capabilities
Networking Tools: Built-in support for networking protocols and tools, making it
ideal for servers and network management.
Desktop Environment
A desktop environment (DE) is a collection of software components that provide a graphical
user interface (GUI) for interacting with an operating system. In the context of Linux, various
desktop environments offer different user experiences, aesthetics, and functionality. Here are
some of the most popular Linux desktop environments:
1. GNOME
Overview: One of the most widely used desktop environments, known for its
simplicity and modern design.
Features:
o Intuitive interface with a dock for applications.
o Activities overview for managing windows and launching apps.
o Highly customizable with extensions.
2. KDE Plasma
Overview: A feature-rich and highly customizable environment that offers a
traditional desktop feel.
Features:
o Extensive customization options for look and behavior.
o Widgets for adding functionality to the desktop.
o Strong integration of applications and services.
3. XFCE
Overview: Lightweight and fast, suitable for older hardware or users who prefer a
minimalistic interface.
Features:
o Simple and straightforward design.
o Customizable panels and menus.
o Good performance with low resource consumption.
4. LXQt
Overview: A lightweight desktop environment that is a continuation of LXDE,
designed for efficiency.
Features:
o Modern look with a focus on performance.
o Low memory usage, making it ideal for older machines.
o Customizable panel and application launcher.
5. Cinnamon
Overview: Developed for the Linux Mint distribution, it offers a traditional desktop
experience with modern features.
Features:
o Familiar layout with a bottom panel and a start menu.
o Easy to use, especially for users transitioning from Windows.
o Good customization options.
6. MATE
Overview: A continuation of the GNOME 2 desktop, MATE provides a classic
desktop experience.
Features:
o Familiar interface reminiscent of older versions of GNOME.
o Lightweight and efficient, suitable for various hardware.
o Easy to customize and configure.
7. Deepin
Overview: Known for its visually appealing design, it’s based on Debian and focuses
on user experience.
Features:
o Sleek and elegant interface with a unique launcher.
o Integrated applications for various tasks.
o User-friendly and aesthetically pleasing.
8. i3 and Other Tiling Window Managers
Overview: Tiling window managers (like i3, bspwm, and Awesome) manage
windows by automatically arranging them without overlapping.
Features:
o Keyboard-driven, allowing for efficient navigation and management.
o Highly customizable and suitable for power users.
o Minimalist approach, focusing on functionality over aesthetics.
5. File Permissions
chmod: Change file permissions.
o chmod 755 file.txt: Set read, write, and execute permissions.
6. Networking Commands
ping: Test network connectivity.
o ping example.com: Check connection to a domain.
1. I/O Redirection
I/O redirection allows you to change the standard input, output, or error of commands.
Standard Input (stdin): Usually the keyboard.
Standard Output (stdout): Usually the terminal screen.
Standard Error (stderr): Also usually the terminal, used for error messages.
Common Redirection Operators:
1. Redirects stdout to a file, overwriting it.
echo "Hello, World!" > output.txt
2. Appends stdout to a file.
echo "Hello again!" >> output.txt
3. Redirects a file as stdin
sort < unsorted.txt
2. Pipes
Pipes (|) allow you to use the output of one command as the input to another command. This
is useful for chaining commands together.
Example:
ls -l | grep ".txt"
3. Filters
Filters are commands that take input, process it, and output the result. Common filters
include:
grep: Searches for specific patterns in text.
cat file.txt | grep "search_term"
sort: Sorts lines of text.
cat file.txt | sort
uniq: Removes duplicate lines.
4. Wildcards
Wildcards are special characters that represent one or more characters in file names. They are
useful for matching patterns.
Common Wildcards:
Matches any number of characters.
ls *.txt # Lists all .txt files
Matches exactly one character.
ls file?.txt # Matches file1.txt, file2.txt, etc.
Matches any one character within the brackets.
ls file[123].txt # Matches file1.txt, file2.txt, file3.txt
Changing Access Rights.
ChatGPT said:
ChatGPT
Changing access rights (or permissions) in Linux is an essential part of managing file security
and user access. Linux uses a permission system to control who can read, write, or execute
files and directories. Here’s how you can change access rights using the chmod, chown, and
chgrp commands.
1. Understanding Permissions
Each file or directory has three types of permissions:
Read (r): Permission to read the file or list the directory contents.
Write (w): Permission to modify the file or add/delete files in the directory.
Execute (x): Permission to run the file as a program or access the directory.
Permissions are assigned to three categories of users:
Owner: The user who owns the file.
Group: Users who are part of the file’s group.
Others: All other users.
2. Viewing Permissions
Use the ls -l command to view permissions:
ls -l filename
-rwxr-xr-- 1 user group 1234 Jan 01 12:00 filename
o g: group
o o: others
o a: all (user, group, others)
Examples:
Add execute permission for the owner:
chmod u+x filename
Remove read permission for others:
chmod o-r filename
Set read and write permissions for the group:
chmod g+rw filename
Set specific permissions (e.g., rwxr-xr--):
chmod 751 filename
Numeric Mode:
Permissions can also be represented numerically:
4: Read
2: Write
1: Execute
Combine these values:
7: Read, Write, Execute (4+2+1)
6: Read, Write (4+2)
5: Read, Execute (4+1)