Advanced Databases
Database Architectures
1.1 Centralized and Client-Server Architectures
• Centralized Architecture:
o All data is stored and managed on a single central server.
o Users access data through terminals or dumb clients.
o Example: Early mainframe systems.
o Advantages: Easier management, high security.
o Disadvantages: Single point of failure, performance bottleneck.
Example: A university uses a single server to store student data, timetable, and attendance. All
department PCs access this central server.
If the server goes down, no one can access the data.
• Client-Server Architecture:
o Divides workload between server (stores and processes data) and clients (user
interface).
o Example: Web applications.
o Advantages: Scalable, interactive, load distributed.
o Disadvantages: More complex, network dependency.
Example: Banking system.
• Client: ATM or mobile app.
• Server: Central banking database that handles transaction requests.
1.2 2-Tier and 3-Tier Architecture
• 2-Tier Architecture:
o Client directly communicates with the database server.
o UI + Business Logic on the client; DBMS on the server.
o Pros: Simple, faster for small-scale applications.
o Cons: Not scalable, difficult to manage security.
Example: Library management system.
• Tier 1 (Client): GUI built in Java or .NET for staff to issue books.
• Tier 2 (Server): MySQL database running on a local server.
3-Tier Architecture:
o Separates presentation, logic, and data layers.
o Layers: Client (UI), Application Server (Business Logic), Database Server.
o Pros: More secure, scalable, better for enterprise apps.
o Cons: More complex, slight overhead.
Example: Online shopping website.
• Presentation Layer: Web browser interface.
• Application Layer: Business logic (e.g., add to cart, apply discount).
• Data Layer: PostgreSQL database.
1.3 Parallel Databases
• Introduction:
o Databases that use parallel processing to perform tasks faster.
o Run queries over multiple processors simultaneously.
• Key Elements:
o Speedup: Execution time decreases with more processors.
Example:
1 processor takes 10 seconds; 5 processors take 2 seconds → speedup = 5x.
o Scaleup: Ability to handle larger databases with added resources.
Example:
Database size and number of processors both double → response time remains the
same.
o Data Partitioning: Data split across processors.
o Load Balancing: Equal work distribution.
• Architectures:
o Shared Memory: All processors access a common memory.
Example: Oracle Parallel Server.
o Shared Disk: Separate memory, shared disk.
Example: IBM DB2 with GPFS (General Parallel File System).
o Shared Nothing: Each processor has own memory and disk (most scalable).
Example: Google Bigtable or Amazon Redshift.
1.4 Distributed Databases
• Introduction:
o Databases spread across multiple physical locations.
o Users experience it as a single database.
Example: Global bank with databases in the USA, Europe, and Asia that sync regularly.
• Architecture:
o Homogeneous: Same DBMS across all sites.
Example: Oracle databases in New York and London using the same schema.
o Heterogeneous: Different DBMS at different sites.
Example: MySQL in India, Oracle in USA working together using middleware.
o Components: Local DBMSs, Global directory, Communication network.
• Distributed Database Design:
o Data Fragmentation: Divide database into smaller parts.
▪ Horizontal, Vertical, Mixed.
Example:
• Horizontal: Student records split by campus location.
• Vertical: One site stores student names and IDs, another stores marks and attendance.
o Data Replication: Copies of data at multiple sites.
Example: Customer data is copied to servers in Mumbai, Delhi, and Bangalore.
o Data Allocation: Deciding where each fragment/replica should be stored.
Example: Inventory data for northern stores kept on a Delhi server.
o Goal: Transparency, fault tolerance, and performance.
2. Emerging Database Technologies
2.1 Introduction
• New database models are developed to handle Big Data, real-time analytics, and
unstructured data.
2.2 NoSQL Databases
• “Not Only SQL”: Designed for unstructured/semi-structured data.
• Types:
o Key-Value Stores (e.g., Redis)
o Document Stores (e.g., MongoDB)
o Column-Family Stores (e.g., Cassandra)
o Graph Databases (e.g., Neo4j)
• Advantages: Schema-less, high scalability, fast for specific use cases.
• Use Cases: Social media, IoT, real-time analytics.
2.3 Internet Databases
• Databases accessed over the internet (e.g., web apps, e-commerce).
• Often use REST APIs for access.
• Need for security, high availability, and performance.
Example: A blog website storing posts and comments in a database accessible via a REST
API.
2.4 Cloud Databases
• Hosted on cloud platforms (e.g., AWS RDS, Azure SQL).
• Features: Scalability, pay-per-use, managed services.
• Types: Relational (SQL), NoSQL, Multi-model.
• Advantages: Cost-effective, maintenance-free for users.
Example: Amazon RDS hosting a MySQL database.
Automatically handles backups and scaling.
2.5 Mobile Databases
• Databases designed to run on mobile devices.
• Work in online and offline modes.
• Lightweight, low memory footprint.
• Example: SQLite, Realm.
Example: WhatsApp uses SQLite to store chat history locally on the device.
2.6 SQLite Database
• Lightweight, embedded relational DBMS.
• Used in Android, iOS, browsers.
• No server: All data is stored in a local file.
• SQL-compatible, zero-configuration.
• Example Code (Android):
CREATE TABLE Students (
ID INTEGER PRIMARY KEY,
Name TEXT,
Marks INTEGER
);
o Database stored as [Link] on the device.
2.7 XML Databases
• Used to store, query, and manage XML data.
• Two types:
o Native XML databases: Store XML documents directly.
o XML-enabled relational databases: Store XML in columns using CLOB or BLOB.
• Query languages: XPath, XQuery.
Example XML:
xml
Copy code
<student>
<name>Alice</name>
<course>DBMS</course>
</student>
• Use Case: Used in e-publishing and healthcare systems to store documents.