KEMBAR78
DBMS Unit - I | PDF | Databases | Art
0% found this document useful (0 votes)
9 views20 pages

DBMS Unit - I

Yes

Uploaded by

faaruofficial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views20 pages

DBMS Unit - I

Yes

Uploaded by

faaruofficial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

M.

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.

Introduction to File system:


o Files: These are the basic units of storage. A file is a collection of data that can
be anything from a document to an application.
o Directories (Folders): These are containers that organize files and other
directories. They help in structuring and categorizing data.
File System Structure:
o Root Directory: The top-level directory in a file system hierarchy. All other
files and directories branch from this root.
o Paths: The location of a file or directory in the file system is defined by a
path, which is a sequence of directory names separated by slashes (e.g.,
/home/user/document.txt).
Metadata:
o File Attributes: Information about a file such as its name, size, type, creation
date, and permissions.
o Inodes: In many file systems, an inode is a data structure that stores
information about a file or directory, including its metadata and location on the
disk.
File System Operations:
o Creation: Creating new files and directories.
o Deletion: Removing files and directories.
o Reading/Writing: Accessing and modifying the content of files.
o Permissions: Setting and enforcing access controls to ensure that only
authorized users can read, write, or execute files.
Types of File Systems:
o FAT (File Allocation Table): An older file system that is simple and widely
supported, often used in flash drives and memory cards.
o NTFS (New Technology File System): Used primarily by Windows operating
systems, NTFS supports large files and advanced features like file permissions
and encryption.
o EXT (Extended File System): Common in Linux environments, with
versions such as EXT3 and EXT4, known for its robustness and performance.
o APFS (Apple File System): Designed by Apple for macOS and iOS devices,
with features like encryption and improved performance.

Database System Structure


Components of a Database System
Query Processor, Storage Manager, and Disk Storage. These are explained as following
below.

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.

 Transaction Manager: It controls concurrent access by performing the operations in a


scheduled way that it receives the transaction. Thus, it ensures that the database
remains in the consistent state before and after the execution of a transaction.

 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:-

1. Conceptual Data Model


The conceptual data model describes the database at a very high level and is useful to
understand the needs or requirements of the database. It is this model, that is used in the
requirement-gathering process i.e. before the Database Designers start making a particular
database. One such popular model is the entity/relationship model (ER model). The E/R
model specializes in entities, relationships, and even attributes that are used by database
designers. In terms of this concept, a discussion can be made even with non-computer
science(non-technical) users and stakeholders, and their requirements can be understood.
Entity-Relationship Model( ER Model): It is a high-level data model which is used to define
the data and the relationships between them. It is basically a conceptual design of any
database which is easy to design the view of data.
Components of ER Model:
1. Entity: An entity is referred to as a real-world object. It can be a name, place, object,
class, etc. These are represented by a rectangle in an ER Diagram.
2. Attributes: An attribute can be defined as the description of the entity. These are
represented by Ellipse in an ER Diagram. It can be Age, Roll Number, or Marks for a
Student.
3. Relationship: Relationships are used to define relations among different entities.
Diamonds and Rhombus are used to show Relationships.
2. Representational Data Model
This type of data model is used to represent only the logical part of the database and does not
represent the physical structure of the database. The representational data model allows us to
focus primarily, on the design part of the database. A popular representational model is
a Relational model. The relational Model consists of Relational Algebra and Relational
Calculus. In the Relational Model, we basically use tables to represent our data and the
relationships between them. It is a theoretical concept whose practical implementation is
done in Physical Data Model.
The advantage of using a Representational data model is to provide a foundation to form the
base for the Physical model
3. Physical Data Model
The physical Data Model is used to practically implement Relational Data Model.
Ultimately, all data in a database is stored physically on a secondary storage device such as
discs and tapes. This is stored in the form of files, records, and certain other data structures. It
has all the information on the format in which the files are present and the structure of the
databases, the presence of external data structures, and their relation to each other. Here, we
basically save tables in memory so they can be accessed efficiently. In order to come up with
a good physical model, we have to work on the relational model in a better way. Structured
Query Language (SQL) is used to practically implement Relational Algebra.
This Data Model describes HOW the system will be implemented using a specific DBMS
system. This model is typically created by DBA and developers. The purpose is actual
implementation of the database.

Introduction to Network Models:


Network models are frameworks that describe and manage the structure and behavior of
computer networks. They help in understanding how different components in a network
interact, communicate, and operate.
1. Network Topology: Refers to the physical or logical layout of nodes (devices) and
their connections. Common topologies include:
o Bus: All devices connect to a single central cable.
o Star: Devices connect to a central hub or switch.
o Ring: Devices are connected in a circular fashion.
o Mesh: Every device connects to every other device.
2. Network Protocols: Rules and standards that manage data transmission and
communication between devices. Examples include:
o TCP/IP: A suite of protocols for internet communication, including
Transmission Control Protocol (TCP) for reliable transmission and Internet
Protocol (IP) for addressing and routing.
o HTTP: Used for transferring web pages.
o FTP: Used for file transfers.
3. Network Layers: Models that organize and define network communication in layers:
o OSI Model: Seven layers, including Physical, Data Link, Network, Transport,
Session, Presentation, and Application.
o TCP/IP Model: Four layers, including Link, Internet, Transport, and
Application.
4. Network Security: Mechanisms to protect networks from unauthorized access and
attacks. Includes:
o Firewalls: Control network traffic based on security rules.
o VPNs: Encrypt data to securely connect remote users.
ER Model:
Peter Chen developed the ER diagram in 1976. The ER model was created to provide a
simple and understandable model for representing the structure and logic of databases. It has
since evolved into variations such as the Enhanced ER Model and the Object Relationship
Model
The Entity Relational Model is a model for identifying entities to be represented in the
database and representation of how those entities are related. The ER data model specifies
enterprise schema that represents the overall logical structure of a database graphically.
The Entity Relationship Diagram explains the relationship among the entities present in the
database. ER models are used to model real-world objects like a person, a car, or a company
and the relation between these real-world objects. In short, the ER Diagram is the structural
format of the database.
Why Use ER Diagrams In DBMS?
 ER diagrams represent the E-R model in a database, making them easy to convert into
relations (tables).
 ER diagrams provide the purpose of real-world modeling of objects which makes
them intently useful.
 ER diagrams require no technical knowledge and no hardware support.
 These diagrams are very easy to understand and easy to create even for a naive user.
 It gives a standard solution for visualizing the data logically.
A solid grasp of the ER Model is crucial for excelling in exams like GATE, where database
management is a key topic. To enhance your understanding and boost your exam preparation,
consider the GATE CS Self-Paced Course . This course offers in-depth coverage of the ER
Model and other essential database concepts, helping you build the knowledge needed to
succeed in your exams.

Symbols Used in ER Model


ER Model is used to model the logical view of the system from a data perspective which
consists of these symbols:
 Rectangles: Rectangles represent Entities in the ER Model.
 Ellipses: Ellipses represent Attributes in the ER Model.
 Diamond: Diamonds represent Relationships among Entities.
 Lines: Lines represent attributes to entities and entity sets with other relationship
types.
 Double Ellipse: Double Ellipses represent Multi-Valued Attributes.
 Double Rectangle: Double Rectangle represents a Weak Entity.

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.

10. Extensive Software Repository


 Package Management: Most distributions come with package managers (like APT,
YUM) that simplify software installation and updates.
11. Command-Line Interface (CLI)
 Powerful Tools: The CLI offers powerful utilities for system management, scripting,
and automation.
12. Community and Documentation
 Supportive Community: A vast user base provides forums, documentation, and
tutorials for assistance.
 Comprehensive Documentation: Extensive online resources cover everything from
basic commands to advanced system administration.

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.

Basic Linux commands


1. File and Directory Commands
 ls: List files and directories.
o ls -l: Detailed listing.

o ls -a: Include hidden files.

 cd: Change directory.


o cd /path/to/directory: Move to the specified directory.

o cd ..: Move up one directory.

 pwd: Print the current working directory.


 modern: Create a new directory.
o modern new directory: Create a directory named "new directory."

 rmdir: Remove an empty directory.


 rm: Remove files or directories.
o rm file.txt: Remove a file.

o rm -r directory name: Remove a directory and its contents.

 cp: Copy files or directories.


o cp source.txt destination.txt: Copy a file.

o cp -r source directory/ destination directory/: Copy a directory.

 mv: Move or rename files or directories.


o mv old_name.txt new_name.txt: Rename a file.

o mv file.txt /path/to/directory/: Move a file to a different directory.

2. File Viewing and Editing


 cat: Display the contents of a file.
o cat file.txt: Show the content of "file.txt."

 less: View file content page by page.


o less file.txt: Open "file.txt" for scrolling.

 nano: A simple text editor.


o nano file.txt: Edit "file.txt" in the nano editor.

 vim: A powerful text editor (more advanced).


o vim file.txt: Open "file.txt" in vim.

3. System Information Commands


 top: Display active processes and system resource usage.
 htop: An enhanced version of top (may need to be installed).
 df: Report file system disk space usage.
o df -h: Show sizes in human-readable format.

 free: Display memory usage.


o free -h: Show memory usage in human-readable format.

 uname: Show system information.


o uname -a: Display all system information.

4. User Management Commands


 whoami: Show the current logged-in user.
 adduser: Add a new user.
o sudo adduser username: Create a new user.

 passwd: Change user password.


o passwd username: Change the password for the specified user.

5. File Permissions
 chmod: Change file permissions.
o chmod 755 file.txt: Set read, write, and execute permissions.

 chown: Change file owner.


o sudo chown user:group file.txt: Change ownership of a file.

6. Networking Commands
 ping: Test network connectivity.
o ping example.com: Check connection to a domain.

 ifconfig or Ip a: Show network interface configuration.


 curl: Transfer data from or to a server.
o curl http://example.com: Fetch the webpage.

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

The first column shows the permissions:


 rwx for the owner
 r-x for the group
 r-- for others
3. Changing Permissions with chmod
The chmod command changes the access rights of files and directories.
Syntax:
[options] mode file
Modes:
 Symbolic mode: Use letters to specify changes.
o u: owner (user)

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)

You might also like