Skip to content

Instantly share code, notes, and snippets.

View k26rahul's full-sized avatar

Rahul Maurya k26rahul

View GitHub Profile
[
{
"url": "https://raw.githubusercontent.com/mhshariatipour1378/Avatars-Placeholder/master/back-end/images/girl/AV64.png",
"testimonial": "I shine bright and move forward fearlessly—nothing can hold me back.",
"name": "Vidu"
},
{
"url": "https://raw.githubusercontent.com/mhshariatipour1378/Avatars-Placeholder/master/back-end/images/boy/AV2.png",
"testimonial": "Life sparkles everywhere I look, like a sky full of stars waiting to be admired.",
"name": "Rahul"
[
{
"subject": "Hello Vidu",
"body": "You are the best person",
"date": "2024-09-24"
},
{
"subject": "Hello Rahul",
"body": "You are a magician",
"date": "2024-09-25"
export const data = [
{
subject: 'Hello Vidu',
body: 'You are the best person',
date: '2024-09-24',
},
{
subject: 'Hello Rahul',
body: 'You are a magician',
date: '2024-09-25',
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 7;
// Shortcut for commonly used data types
typedef vector<int> vi;
typedef pair<int, int> pii;
// Fast I/O for standard input and output

Fixed-Length Records: In a library database, a fixed-length record structure is used to store book information.

  • Record Length: Each record is always 100 characters long, regardless of content.
  • Fields:
    • Title (30 characters)
    • Author (20 characters)
    • ISBN (13 characters)
    • Publication Year (4 characters)
  • Genre (10 characters)

Database Buffer

  • Purpose: The database buffer is a crucial component in database management. It acts as a cache, temporarily storing data from the disk in memory to facilitate quicker data access.

  • Buffer Replacement Policies: Different strategies are employed to replace data in the buffer, ensuring that frequently accessed data remains in memory. Common policies include Least Recently Used (LRU) and First-In, First-Out (FIFO).

  • Example (LRU): Imagine you have a buffer with limited space. When new data needs to be loaded into the buffer, the Least Recently Used (LRU) policy will evict the data that hasn't been accessed for the longest time to make room for the new data. This keeps the most recently used data in memory for faster access.

  • Example (FIFO): In a First-In, First-Out (FIFO) buffer, data that entered the buffer first is the first to be removed when new data needs to be loaded. It's like a queue; the data that arrived earlier is served first.

Chapter 10: Storage and File Structure

10.1 Overview of Physical Storage Media

  • Purpose: Understanding the physical media where data is stored is crucial for optimizing database performance and efficiency.
  • Magnetic Disk: This is a primary storage medium used in database systems. Data is organized in tracks and sectors, and it's the most common storage medium for traditional databases.
  • Flash Storage: Flash storage, found in Solid-State Drives (SSDs), is faster and non-mechanical. It's increasingly popular for its speed and reliability.
  • Tertiary Storage: Tertiary storage is slower but more cost-effective. It's often used for long-term data archiving.

10.2 Magnetic Disk and Flash Storage

  • Magnetic Disk: These disks are central to data storage. They have fast access times and store data magnetically on spinning platters.

Candidate Keys: A candidate key is a minimal set of attributes in a relational table that uniquely identifies each row, with no redundant attributes. Removing any attribute from it would result in non-uniqueness.

Super Keys: A super key is a set of attributes that can uniquely identify rows but may contain more attributes than necessary to ensure uniqueness.

Example: In a music library's "Songs" table:

Songs Table:

RAID - Redundant Array of Independent Disks

R - Redundancy

  • Data is duplicated and stored on multiple disks.
  • Example: If one disk fails, the data is still accessible from the other disks, ensuring data reliability.

A - Array

  • Multiple disks are grouped together to work as a single unit.
  • Example: Several hard drives are combined to create a larger storage pool or improve performance.

ACID in Financial Transactions

A - Atomicity

  • All parts of a transaction succeed or fail together.
  • Example: When transferring money from one account to another, either the entire transfer happens or none of it does.

C - Consistency

  • The database starts in a consistent state and ends in a consistent state.
  • Example: If an account has $100, a withdrawal cannot leave it with a negative balance.