0% found this document useful (0 votes)
49 views31 pages

DBMS Unit 1 Very Short

A Database Management System (DBMS) is software that facilitates the storage, organization, and retrieval of data in a structured format, typically using tables. Key components of a DBMS include data integrity, security, backup and recovery, and various architectures such as one-tier, two-tier, and three-tier systems. The document also covers essential concepts like data models, functional dependencies, normalization, and the differences between database systems and file systems.

Uploaded by

gogofhyr
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)
49 views31 pages

DBMS Unit 1 Very Short

A Database Management System (DBMS) is software that facilitates the storage, organization, and retrieval of data in a structured format, typically using tables. Key components of a DBMS include data integrity, security, backup and recovery, and various architectures such as one-tier, two-tier, and three-tier systems. The document also covers essential concepts like data models, functional dependencies, normalization, and the differences between database systems and file systems.

Uploaded by

gogofhyr
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/ 31

🔹 What is a DBMS?

A Database Management System (DBMS) is software that helps you store, organize, update, and
find data easily. It is like a smart system that manages information in tables.
🔹 Key Parts of DBMS:
 Data: Information like names, numbers, images, etc.

 Database: A collection of this data stored in an organized way.

 Schema: A blueprint that tells how data is arranged.

 Data Manipulation: You can add, update, delete, or find data using languages like SQL.

 Security: Only authorized people can access certain data.

 Data Integrity: Makes sure data is accurate and consistent.

 Backup and Recovery: Keeps copies of data safe in case something goes wrong.

 Concurrency: Handles many people using the system at once without issues.

 Indexing: Speeds up searching for data.

 Scalability: Can grow to handle more users and more data.

 Redundancy Control: Avoids saving the same data more than once.

🔹 Database System vs. File System

Database File
Feature
System System

Data Structure Uses tables Stores in


Database File
Feature
System System

(rows and files and


columns) folders

No
automatic
Ensures
checks;
Data Integrity accuracy
user has
using rules
to
manage it

Needs
Can search
manual
Querying data using
reading of
SQL
files

Supports
No built-
relationships
Data Relationships in way to
like "one-to-
relate files
many"

Can have
Reduces
Redundancy duplicate
duplicates
data

Not good
Handles at
Concurrency many users handling
at once multiple
users

Less
Designed to efficient
Scalability
grow easily for big
data
Database File
Feature
System System
🔹 Types of DBMS Architecture

1️⃣ One-Tier Architecture

 Everything is on one machine.

 Used for learning or small personal projects.

 Simple, cheap, but not used in large companies.

2️⃣ Two-Tier Architecture

 A client (user) talks directly to a server (database).

 Used in small-scale applications.

 Faster and easier but struggles with many users.

3️⃣ Three-Tier Architecture

 Has a middle layer (application server) between client and database.


 Used in big applications like websites.

 More secure and scalable, but more complex.

🔹 Data Models

A data model shows how data is arranged in a database.

Types:

 Relational Model: Data is in tables (rows and columns).

 ER (Entity-Relationship) Model: Uses diagrams to show entities (like Student, Course) and
their relationships.

 Object-Based Model: Adds object-oriented concepts like inheritance.

 Semi-Structured Model: Like XML or JSON; flexible structure.

🔹 Schema & Instance

 Schema: The design of the database (like a blueprint).

 Instance: The actual data stored at a specific time (like a snapshot).

🔹 Concepts of Database System

 Data: Can be structured (tables), semi-structured (XML), or unstructured (images).

 DBMS: Manages and works with the data.

 Database: The storage area for organized data.

 Query Language: Used to interact with the data (e.g., SQL).

🔹 DBMS Components

 User Interface: How users talk to the DBMS (GUI, SQL, Web).

 Query Processor: Understands and runs SQL queries.

 Storage Manager: Handles storing data on disk.

 Buffer Manager: Manages memory to speed things up.

 Transaction Manager: Makes sure operations are safe and complete.

 Data Dictionary: Keeps info about database structure.

 Concurrency Control: Manages multiple users.

 Backup and Recovery: Keeps data safe and can restore it.
🔹 ER Model (Entity-Relationship Model)

Used to plan databases visually.

 Entity: Real-world object (like Student, Course).

 Attributes: Details about an entity (like Name, Age).

 Relationships: How entities are connected (e.g., a student enrolls in a course).

 Diagram Symbols:

o Rectangle = Entity

o Oval = Attribute

o Diamond = Relationship

Example:

scss

CopyEdit

Student (StudentID, Name, Age)

Course (CourseCode, Title, Credits)

Relationship: Student ENROLLS in Course

An ER Model (Entity-Relationship Model) in DBMS (Database Management System) is a high-level


conceptual data model used to define the data elements and their relationships for a given system.
It provides a blueprint for designing databases and is typically represented using ER diagrams.

🧩 Key Components of ER Model

1. Entities

o Represent real-world objects or concepts.

o Each entity has a set of attributes.

o Example: Student, Course, Employee.

Types:

o Strong Entity: Has a primary key.

o Weak Entity: Cannot be uniquely identified by its attributes alone.

2. Attributes

o Describe properties of an entity.


o Example: Student has attributes like Student_ID, Name, DOB.

Types:

o Simple / Atomic: Cannot be divided (e.g., Age).

o Composite: Can be divided into sub-parts (e.g., Name → FirstName, LastName).

o Derived: Can be derived from other attributes (e.g., Age from DOB).

o Multivalued: Can have multiple values (e.g., PhoneNumbers).

3. Relationships

o Represent associations between entities.

o Example: Student enrolls in Course.

Types:

o One-to-One (1:1)

o One-to-Many (1:N)

o Many-to-Many (M:N)

o 1. One-to-One (1:1)

o Each entity in Table A is related to only one entity in Table B, and vice versa.

o Rare in practice but used for splitting data for security or efficiency.

o Example:

o Each Person has one Passport.

o Each Passport belongs to only one Person.

o PersonID o Name o PassportID

o 1 o John o P123

o PassportID o IssueDate

o P123 o 2020-01-01

o 2. One-to-Many (1:N)

o One entity in Table A relates to many entities in Table B.

o Common in databases.

o Example:

o One Department has many Employees.

o Each Employee belongs to one Department.


o DeptID o DeptName

o 101 o Sales

o EmpID o EmpName o DeptID

o 1 o Alice o 101

o 2 o Bob o 101

o 3. Many-to-Many (M:N)

o Entities in Table A relate to many entities in Table B and vice versa.

o Requires a junction table to implement.

o Example:

o Students enroll in Courses.

o Each student can enroll in many courses.

o Each course can have many students.

o StudentID o Name

o 1 o John

o CourseID o CourseName

o C101 o Math

o StudentID o CourseID

o 1 o C101

4. Keys

o Primary Key: Uniquely identifies each entity instance (e.g., Student_ID).

o Foreign Key: Refers to the primary key in another entity.

5. 🔑 Keys in DBMS

6. Keys are attributes (one or more columns) that help identify rows uniquely in a table or
establish relationships between tables.

7.

8. 1. Primary Key (PK)

9. Uniquely identifies each record in a table.

10. Cannot be NULL.


11. Each table can have only one primary key.

12. Example:

13. StudentID (PK) 14. Name 15. Age

16. 101 17. Alice 18. 20

19. 102 20. Bob 21. 22

22.

23. 2. Candidate Key

24. A set of attributes that can uniquely identify rows.

25. There can be multiple candidate keys.

26. One candidate key is chosen as the primary key.

27. Example:
In a table:

28. StudentID 29. Email (Candidate Key) 30. Name

31. 101 32. [email protected] 33. Alice

34. 102 35. [email protected] 36. Bob

37. Both StudentID and Email can uniquely identify a student.

38.

39. 3. Alternate Key

40. Candidate keys which are not chosen as primary key.

41. Example:
If StudentID is primary key, Email becomes an alternate key.

42.

43. 4. Foreign Key (FK)

44. Attribute in one table that refers to the primary key of another table.

45. Used to maintain referential integrity.

46. Example:

47. StudentID (PK) 48. Name

49. 101 50. Alice

51. CourseID 52. CourseName 53. StudentID (FK)

54. C001 55. Math 56. 101


47. StudentID (PK) 48. Name

57.

58. 5. Super Key

59. Any set of attributes that uniquely identify a row.

60. Primary key is a minimal super key.

61.

62. 6. Composite Key

63. A key made of two or more attributes to uniquely identify a row.

64. Example:
In a CourseRegistration table:

65. StudentID 66. CourseID 67. RegistrationDate

68. Participation

o Total Participation: Every instance must participate in the relationship.

o Partial Participation: Some instances may not participate.

69. Generalization, Specialization, Aggregation

o Generalization: Combining similar entities into a general entity.

o Specialization: Dividing an entity into sub-entities.

o Aggregation: Treating a relationship as a higher-level entity.

📘 ER Diagram Notation

 Rectangle: Entity

 Ellipse: Attribute

 Diamond: Relationship

 Line: Link between components

 Double Rectangle: Weak Entity

 Double Ellipse: Multivalued Attribute

✅ Example
yaml

CopyEdit

Student ——— Enrolls ——— Course

| |

Name Course_Name

Age Credits

 Student and Course are entities.

 Enrolls is a relationship.

 Name, Age, etc., are attributes.

 🔑 Key Attribute vs Non-Key Attribute in DBMS (ER Model)

Aspect Key Attribute Non-Key Attribute


An attribute that uniquely identifies an An attribute that does not uniquely
Definition
entity. identify an entity.
Used to differentiate one entity
Purpose Used to describe the entity further.
instance from another.
Must have unique values for each Can have duplicate values across
Uniqueness
entity instance. entities.
Primary keys, foreign keys in General attribute set, not used in
Used in
database design. identification.
Name, Age, Department in a Student
Example Student_ID in a Student entity.
entity.

A complex attribute is an attribute that is composed of multiple components, which may include
both simple (atomic) and multivalued attributes. It is essentially a combination of composite and
multivalued attributes.

🔗 Functional Dependency in DBMS

Functional Dependency (FD) is a relationship between two attributes (or sets of attributes) in a
relation (table) of a database. It is a key concept used in normalization and relational schema
design.

🔹 Definition

A functional dependency X → Y between two sets of attributes X and Y in a relation R means:


"If two tuples (rows) have the same value for attribute(s) X, then they must have the same value
for attribute(s) Y."

In other words, X determines Y.

✅ Example:

Let’s consider a Student table:

Roll_No Name Dept

101 Alice CS

102 Bob IT

103 Alice CS

Here:

 Roll_No → Name means if Roll_No is the same, Name must be the same.

 Roll_No → Dept means Roll_No uniquely determines Dept.

🧩 Types of Functional Dependencies

Type Description

Trivial FD A → A or A,B → A (RHS is part of LHS)

Non-Trivial FD A → B where B is not part of A

Full Functional X → Y, and Y is not functionally dependent on any proper subset of X

Partial Functional X → Y, but Y is also dependent on a part of X

Transitive Dependency If X → Y and Y → Z, then X → Z (through Y)

Multivalued Dependency One attribute determines multiple independent values of another

📘 Notation:

 X → Y: X functionally determines Y

 X: Determinant

 Y: Dependent

🧠 Use of Functional Dependencies:

 To find candidate keys

 To perform normalization (like 1NF, 2NF, 3NF, BCNF)


 To detect and remove redundancy in database tables

Normalization in DBMS (Database Management System) is the process of organizing data in a


database to reduce redundancy and improve data integrity. The goal is to decompose larger tables
into smaller, manageable ones while maintaining relationships between them.

🔧 Why Normalization is Needed:

1. Avoid Data Redundancy: Prevent storing the same data in multiple places.

2. Ensure Data Integrity: Ensure data is consistent and correct.

3. Improve Query Efficiency: Simpler and faster queries due to structured data.

4. Make Database Maintenance Easier: Updates, deletions, and insertions are more
manageable.

📚 Normal Forms:

Normalization is done through stages called normal forms (NFs). Each form has a specific set of
rules.

👉 1. First Normal Form (1NF):

 Eliminate repeating groups.

 Ensure each column contains atomic (indivisible) values.

Example:

Student Courses

John Math, Science

→ 1NF Conversion:

Student Course

John Math

John Science

👉 2. Second Normal Form (2NF):

 Must be in 1NF.

 Remove partial dependencies (non-prime attribute depending on part of a candidate key).


Example:
A table with composite key (StudentID, CourseID) where StudentName depends only on StudentID.

→ 2NF Conversion: Separate student and course info into different tables.

👉 3. Third Normal Form (3NF):

 Must be in 2NF.

 Remove transitive dependencies (non-prime attribute depending on another non-prime


attribute).

Example:
If a table has: StudentID → DepartmentID → DepartmentName, then StudentID →
DepartmentName is a transitive dependency.

→ 3NF Conversion: Move Department info to a separate table.

👉 4. Boyce-Codd Normal Form (BCNF):

 Stricter version of 3NF.

 Every determinant must be a candidate key.

👉 Higher Normal Forms:

 4NF: Remove multi-valued dependencies.

 5NF: Deal with join dependencies.

 6NF (rare): Decomposes data further to support temporal databases.

🎯 Summary Table:

Normal Form Key Rule

1NF Atomic values, no repeating groups

2NF No partial dependency

3NF No transitive dependency

BCNF Every determinant is a candidate key

4NF No multi-valued dependencies

5NF No join dependencies


RDBMS stands for Relational Database Management System. It's a type of database management
system (DBMS) that stores data in a structured format, using rows and columns — essentially, in
tables.

Key Concepts of RDBMS:

1. Tables (Relations):

o Data is organized into tables.

o Each table has rows (records) and columns (fields).

2. Primary Key:

o A unique identifier for each record in a table.

3. Foreign Key:

o A field in one table that links to the primary key of another table, establishing a
relationship between the tables.

4. SQL (Structured Query Language):

o The standard language used to interact with RDBMS (e.g., to query, insert, update,
and delete data).

5. Data Integrity:

o Enforced through constraints like NOT NULL, UNIQUE, CHECK, and relationships (via
foreign keys).

6. ACID Properties (for transactions):

o Atomicity: All or nothing.

o Consistency: Data must be valid after a transaction.

o Isolation: Transactions don’t interfere with each other.

o Durability: Data is permanently saved.

Popular RDBMS Software:

 MySQL

 PostgreSQL

 Oracle Database

 Microsoft SQL Server

 SQLite

Example Table:

Customers
CustomerID Name Email

1 Alice [email protected]

2 Bob [email protected]

Each row is a record, and each column represents a piece of data (attribute) about the record.

Let me know if you want a deeper dive into any part — like SQL queries or how relationships work.

4o

You said:

differnece between dbms and dbms

ChatGPT said:

It looks like you wrote "difference between DBMS and DBMS" — I think you meant:

Difference between DBMS and RDBMS

Here’s a clear comparison:

DBMS (Database Management RDBMS (Relational Database


Feature
System) Management System)

Stores data as files, or collections of


Data Storage Stores data in tables (relations)
records

Relationship Supports relationships using primary


No relationships between data
Between Data and foreign keys

Enforces data integrity with constraints


Data Integrity No strict rules on data integrity
(e.g., unique, not null)

Supports normalization to reduce


Normalization Usually not supported
redundancy

Always uses SQL for querying and


Query Language May or may not use SQL
managing data

Supports multi-user access with proper


Multi-user Access Limited or not supported
concurrency control

File system, XML-based systems, MySQL, Oracle, PostgreSQL, SQL Server,


Examples
Microsoft Access (basic) SQLite

Fully supports ACID properties for


Transactions (ACID) May not support full ACID properties
transactions

💾 DML – Data Manipulation Language

DML is used to manipulate or manage the data stored in the database.


Common DML Commands:

Command Description

SELECT Retrieves data from one or more tables

INSERT Adds new records to a table

UPDATE Modifies existing records in a table

DELETE Removes records from a table

Example:

sql

CopyEdit

INSERT INTO Students (Name, Age) VALUES ('Alice', 20);

UPDATE Students SET Age = 21 WHERE Name = 'Alice';

🔐 DCL – Data Control Language

DCL is used to control access to data in the database — it deals with permissions and security.

Common DCL Commands:

Command Description

GRANT Gives user access privileges to the database

REVOKE Removes user access privileges

Example:

sql

CopyEdit

GRANT SELECT ON Students TO user1;

REVOKE SELECT ON Students FROM user1;

Summary Table:

Feature DML (Data Manipulation) DCL (Data Control)

Purpose Manage data Manage user permissions

Affects Table data Access control

Common Commands SELECT, INSERT, UPDATE, DELETE GRANT, REVOKE


1. CREATE – Create a new table

sql

CopyEdit

CREATE TABLE Students (

StudentID INT PRIMARY KEY,

Name VARCHAR(100),

Age INT,

Grade VARCHAR(5)

);

✅ This creates a table named Students with four columns.

➕ 2. INSERT – Add data into a table

sql

CopyEdit

INSERT INTO Students (StudentID, Name, Age, Grade)

VALUES (1, 'Alice', 20, 'A');

✅ This adds a new student record to the Students table.

📋 3. SELECT – Retrieve data from a table

sql

CopyEdit

SELECT * FROM Students;

✅ This fetches all records from the Students table.

✏️4. UPDATE – Modify existing data

sql

CopyEdit

UPDATE Students

SET Grade = 'A+'


WHERE StudentID = 1;

✅ This updates the grade for the student with ID 1.

❌ 5. DELETE – Remove data from a table

sql

CopyEdit

DELETE FROM Students

WHERE StudentID = 1;

✅ This deletes the student with ID 1 from the table.

🔒 6. GRANT – Give permissions

sql

CopyEdit

GRANT SELECT, INSERT ON Students TO user1;

✅ This gives user1 permission to select and insert data into Students.

🔓 7. REVOKE – Remove permissions

sql

CopyEdit

REVOKE INSERT ON Students FROM user1;

🔄 Transaction in DBMS

A transaction is a sequence of one or more SQL operations (like insert, update, delete) that are
executed as a single logical unit of work.

Example:
Transferring money from Account A to B:

1. Debit A

2. Credit B
→ Both must succeed, or neither should happen.

✅ ACID Properties of Transactions

ACID ensures reliability, consistency, and integrity of a database even in case of failures.
Property Description

A - Atomicity All operations of a transaction are completed or none. No partial execution.

C - Consistency The database moves from one consistent state to another after a transaction.

I - Isolation Concurrent transactions do not interfere with each other.

Once a transaction is committed, its changes are permanent—even in case of


D - Durability
failure.

🧠 Transaction States

1. Active: Transaction is being executed.

2. Partially Committed: Last statement executed but not yet saved.

3. Committed: All changes are saved permanently.

4. Failed: Something went wrong.

5. Aborted: Changes are rolled back.

🔄 Transaction Control Commands

Command Description

BEGIN or START TRANSACTION Starts a transaction

COMMIT Saves all changes made by the transaction

ROLLBACK Undoes all changes made by the transaction

SAVEPOINT Sets a point within a transaction to roll back to

RELEASE SAVEPOINT Deletes a previously defined savepoint

📚 Indexing in DBMS

An index is a data structure that improves the speed of data retrieval operations on a database
table at the cost of additional writes and storage space.

🔑 Common Indexing Techniques

1. B-Tree Index

 B-Tree (Balanced Tree) is a self-balancing tree data structure that maintains sorted data
and allows searches, sequential access, insertions, and deletions in logarithmic time.
 It is widely used in databases and file systems.

 The tree consists of nodes with multiple keys and children.

 Properties:

o Balanced (all leaf nodes are at the same level).

o Keys in each node are sorted.

o Supports range queries efficiently.

 Use Case: When you need ordered data and range queries like BETWEEN, <, >, etc.

Example:

plaintext

CopyEdit

[17, 35]

/ | \

<17 18-35 >35

2. Hash Index

 Uses a hash function to compute the address of the data.

 Ideal for exact match queries (e.g., WHERE id = 123).

 Provides fast lookup (average O(1) time).

 Does not support range queries efficiently.

 Collisions are handled by chaining or open addressing.

3. Other Index Types (Brief Overview)

 Bitmap Index: Uses bitmaps for each key, efficient for columns with low cardinality.

 Clustered Index: The table rows are stored in the same order as the index.

 Non-clustered Index: Separate structure with pointers to the actual table rows.

 Composite Index: Index on multiple columns.

📝 Summary Comparison

Index Type Search Efficiency Supports Range Queries? Use Case

B-Tree O(log n) Yes Ordered data, range queries

Hash O(1) (average case) No Exact match queries


Index Type Search Efficiency Supports Range Queries? Use Case

Concurrency Control in DBMS

Concurrency control manages simultaneous operations on a database without conflicting,


ensuring consistency and isolation among transactions.

1. Lock-Based Protocols (Locking)

 Transactions lock data items to prevent others from accessing them simultaneously in
conflicting ways.

🔒 Types of Locks:

 Shared Lock (S-lock): For read operations. Multiple transactions can hold shared locks on
the same data.

 Exclusive Lock (X-lock): For write operations. Only one transaction can hold an exclusive
lock on data.

🔑 Lock Protocols:

 Two-Phase Locking (2PL):

o Growing phase: Transaction acquires all the locks it needs.

o Shrinking phase: Transaction releases the locks.

o Guarantees serializability.

Pros:

 Simple and effective.

 Prevents many concurrency problems.

Cons:

 Can cause deadlocks (two transactions waiting forever for each other’s locks).

 Overhead of lock management.

2. Timestamp-Based Protocols

 Each transaction is given a unique timestamp when it starts.

 Transactions are ordered based on timestamps.


 Read and write operations are checked against timestamp rules to maintain serializability.

Key Rules:

 Read rule: Transaction can read data only if no younger transaction has already written it.

 Write rule: Transaction can write only if no younger transaction has read or written the
data.

Pros:

 No waiting, so no deadlocks.

 Good for systems with many read operations.

Cons:

 More complex.

 Can lead to transaction aborts and restarts (cascading aborts).

3. Other Concurrency Control Methods

 Optimistic Concurrency Control:

o Transactions execute without restrictions.

o Validation phase checks for conflicts before commit.

 Multiversion Concurrency Control (MVCC):

o Maintains multiple versions of data.

o Readers don’t block writers and vice versa.

o Used in databases like PostgreSQL and Oracle.

⚡ Summary Table

Method How it Works Pros Cons

Simple, ensures
Locking (2PL) Locks data during transaction Deadlocks, blocking
safety

Timestamp Orders transactions by May abort


No deadlocks
Ordering timestamps transactions

Good for low


Optimistic Control Validate after execution Rollbacks if conflicts
conflicts

More storage
MVCC Multiple versions of data High concurrency
overhead
💾 Database Recovery

Database recovery is the process of restoring a database to a correct state after a failure (like
system crash, power failure, or transaction failure).

🔥 Types of Failures:

 Transaction failure: Error in a transaction.

 System failure: Operating system or hardware crash.

 Media failure: Disk or storage device failure.

 Natural disasters: Fire, flood, etc.

Recovery Techniques:

1. Log-Based Recovery

o Maintain a log file recording all changes.

o Two main types:

 Undo: Roll back incomplete transactions.

 Redo: Reapply committed transactions after crash.

o Examples: Write-Ahead Logging (WAL) protocol.

2. Checkpointing

o Periodically save the state of the database.

o Reduces recovery time by limiting how far back you need to replay logs.

3. Shadow Paging

o Maintain two copies of the database pages: current and shadow.

o Update shadow pages and switch after commit.

💽 Backup Strategies

Backups are copies of the database used to restore data after loss or corruption.

Types of Backups:

Backup Type Description Pros Cons

Complete copy of the entire Time-consuming and large


Full Backup Simple recovery
database size
Backup Type Description Pros Cons

Incremental Backs up only data changed Recovery slower (need all


Faster, smaller size
Backup since last backup increments)

Differential Backs up data changed since Faster recovery than Larger backup size over
Backup last full backup incremental time

📝 Backup and Recovery Best Practices

 Schedule regular backups (full + incremental/differential).

 Use off-site storage or cloud for backups.

 Test recovery process periodically.

 Combine with transaction logs for point-in-time recovery.

 Use RAID or other fault-tolerant storage systems.

You might also like