0% found this document useful (0 votes)
51 views5 pages

Advanced Database Assignment 1

Uploaded by

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

Advanced Database Assignment 1

Uploaded by

jukes
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

RC-REC-002

ASSIGNMENT COVER

REGION: ___________________HARARE__________________________________________________

PROGRAMME: ____________________________SOFTWARE ENGINEERING_______________________


INTAKE:____

FULL NAME OF STUDENT: ______TENDAI MUDE CHIWARA__________________________________


PIN:P2115542Q________

MAILING ADDRESS:
_____tendai@eshagi.com_____________________________________________________

CONTACT TELEPHONE/CELL: _0716726628________________________ ID. NO.:


______6354457K47__________

COURSE NAME: ______ADVANCED DATABASES__________ COURSE CODE: ____ BITH/BSIT/BSSE

_____

ASSIGNMENT NO. e.g. 1 or 2: ______1_____________________ DUE DATE: __1 Novemeber___________

ASSIGNMENT TITLE: _______advanced database assignment 1


final___________________________________________________

______________________________________________________________________________

______________________________________________________________________________

MARKER’S COMMENTS: ______________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________
88%
OVERALL MARK: _____________ Zvirikuzhe
MARKER’S NAME: ________________________

MARKER’S SIGNATURE:_______________________________ 14/11/24


DATE: ___________

Question 1
(a) Compare and contrast relational databases with non-relational databases in terms of
structure, scalability, and typical use cases. Provide examples. (5 Marks)
Relational databases organize data in tables with defined schemas, ensuring integrity through
relationships and foreign keys. They typically scale vertically, requiring hardware upgrades for
increased loads, though some support horizontal scaling via sharding.

Non-relational databases (NoSQL) allow for flexible, unstructured data storage without fixed
schemas. They are designed for horizontal scalability, efficiently distributing data across multiple
servers, making them ideal for high-volume, rapidly changing applications.
[5]
Relational Databases: Best for data integrity applications like banking and ERP systems (e.g.,
MySQL, PostgreSQL).
Non-relational Databases: Suitable for flexible, scalable applications like Big Data and real-time web
apps (e.g., MongoDB, Redis).
Max: 70 words.
(b) Explain the importance of ACID properties in a database system. Discuss how these properties
are managed in a distributed database environment. (5 Marks)

In distributed databases, maintaining ACID properties involves:


 Atomicity: Achieved through the Two-Phase Commit (2PC) protocol, which ensures all
nodes either commit or roll back transactions as a unit.
 Consistency: Upheld by consensus algorithms (such as Paxos or Raft) that make sure all
nodes agree on the state of the data.
[4]
 Isolation: Handled through locking mechanisms and timestamp ordering to safely manage
concurrent transactions.
 Durability: Ensured via data replication across nodes and write-ahead logging,

Max: 80 words
(c) What is the role of indexing in query optimization? Provide an example of how improper
indexing can impact database performance. (5 Marks)

Indexing enhances data retrieval speed in databases by allowing quick access to specific rows
without scanning the entire table. When a query is executed, a database management system
(DBMS) uses indexes to efficiently locate data, significantly reducing response times.
However, improper indexing—such as excessive indexes or indexing rarely queried columns—can
degrade performance. Too many indexes slow down write operations, while unused indexes waste [4]
resources. Thus, effective indexing is crucial for optimizing query performance while avoiding
unnecessary overhead.

Max: 80 Words
(b) Discuss the importance of data privacy and compliance with regulations such as GDPR in
database management. (5 Marks)

 Protection of Personal Information: Ensures secure handling of personal data, safeguarding


against identity theft and unauthorized access.
 Legal Compliance: Organizations must adhere to strict data handling regulations to avoid
severe penalties.
 Trust and Reputation: Responsible data management fosters customer trust and loyalty.
 Data Minimization: GDPR encourages collecting only necessary data, reducing breach risks
and enhancing efficiency.
 Accountability and Transparency: Compliance requires organizations to be accountable and [5]
transparent in their data practices, leading to better governance.

Max: 80 Words
Question 2
(a) Explain the primary characteristics of NoSQL databases. Provide a use case where a
NoSQL database would be more suitable than a relational database, and justify
your choice (10 Marks)

NoSQL databases are tailored for diverse data models, making them ideal for large-scale storage
and real-time web applications. Key features include:
 Schema Flexibility: NoSQL databases can store unstructured or semi-structured data
without a fixed schema, adapting easily to changing needs.
 Horizontal Scalability: They scale out by adding servers, accommodating increased loads
without relying on upgraded hardware.
 High Performance: Optimized for rapid read and write operations, crucial for real-time data
processing.
 Variety of Data Models: They include document stores (like MongoDB), key-value stores
(like Redis), and more, allowing choice based on use case.
[10]
 Eventual Consistency: Many prioritize availability over immediate consistency, ensuring
operation during network partitions.

Max: 120 words


(b) Explore the emerging trend of integrating machine learning with database systems.
How can machine learning enhance database performance. (10Marks)

[Link] Optimization: ML analyzes historical query patterns to suggest efficient execution plans
and indexing strategies.
[Link] Detection: ML monitors database activity to identify unusual patterns, alerting for
potential security breaches or failures.
[Link] Indexing: ML automates index creation by analyzing workloads, reducing manual
efforts for administrators.
[10]
[Link] Maintenance: ML predicts hardware failures or performance issues, allowing proactive
maintenance.
[Link] Classification: ML classifies and clusters data, improving organization and retrieval speeds.
[Link] Security: ML flags deviations in user behavior to detect unauthorized access.
[Link] Caching: ML optimizes caching based on access patterns, improving response times.

(c)Explore the emerging trend of integrating machine learning with database systems. How can
machine learning enhance database performance.
Integrating machine learning (ML) with database systems enhances performance and efficiency in
several ways:
1. Query Optimization: ML analyzes historical data to predict efficient execution plans,
reducing query latency.
2. Intelligent Indexing: Automated indexing based on access patterns optimizes response
times without manual effort.
3. Anomaly Detection: ML detects unusual patterns in transaction logs, alerting for potential
security breaches or system issues.
4. Predictive Analytics: ML forecasts future trends, aiding proactive decision-making.
5. Automated Data Management: Streamlines tasks like load balancing through dynamic
resource allocation.
6. Enhanced Data Retrieval: Natural language processing allows intuitive querying for non-
technical users.
7. Performance Tuning: Continuous monitoring suggests adjustments for optimal resource
usage.
Overall, ML integration leads to smarter, more adaptive database management.
Max: 120 Words
(c) Discuss the Two-Phase Commit Protocol and its role in ensuring data consistency.
(10 Marks)

The Two-Phase Commit (2PC) protocol is a distributed algorithm that ensures all participants in a
transaction either commit or abort, maintaining data consistency across multiple databases or systems. It
consists of two phases:

Prepare Phase: The coordinator sends a “prepare” request to all participant nodes, which perform
local checks to determine if they can commit. Each participant replies with either a “vote commit” [6]
or “vote abort.”
Commit Phase: The coordinator evaluates the votes. If all participants vote to commit, a “commit”
command is sent. If any participant votes to abort, an “abort” command is issued.
While 2PC ensures atomicity and consistency, it faces challenges like blocking (if a participant fails),
a single point of failure at the coordinator, and performance overhead due to required round-trip
communication.

Max: 120 Words

Common questions

Powered by AI

Relational databases primarily scale vertically by upgrading existing hardware, although some support horizontal scaling through sharding. They are ideal for applications requiring data integrity, like banking systems, due to their structured schemas and relationship constraints. Non-relational databases, or NoSQL databases, are designed for horizontal scalability, distributing data across multiple servers, making them suitable for high-volume, rapidly changing applications like real-time web apps. They are preferred when the application demands flexible schema designs and high availability under significant loads .

Integrating machine learning (ML) into database systems enhances performance through query optimization, where ML analyzes historical patterns to suggest efficient execution plans; anomaly detection, identifying unusual activities for security alerts; and automated indexing, which simplifies database optimization. Examples include predictive maintenance for hardware failure prevention, data classification to improve retrieval speeds, and intelligent caching to enhance response times by predicting access patterns. This leads to adaptive, optimized database management .

NoSQL databases offer schema flexibility, horizontal scalability, high performance for read/write operations, and support for diverse data models. A use case where NoSQL is preferable is in real-time web applications requiring rapid scaling and flexible data representation, such as social media platforms. These systems need to handle large volumes of dynamic data across distributed networks efficiently, a scenario that aligns well with NoSQL's strengths in managing unstructured data and scaling horizontally .

Data privacy regulations like GDPR significantly influence database management by mandating secure handling and minimization of personal data to prevent unauthorized access and breaches. Core principles enforced include data protection and privacy, requiring secure data handling and adherence to legal frameworks to avoid penalties; data minimization, encouraging the collection of only necessary information; and accountability and transparency, demanding organizations be accountable and clear about data practices. This fosters trust and ensures responsible data governance .

Improper indexing can degrade database performance by slowing down write operations due to excessive indexes imposing additional overhead. Indexing rarely queried columns wastes resources, while too many indexes can complicate maintenance, leading to suboptimal query execution plans. To avoid these issues, careful analysis of query patterns should guide index creation, ensuring indexes support frequent queries without causing unnecessary bloat. Database administrators should regularly review and optimize indexes as access patterns change .

ACID properties ensure reliable transactions in distributed databases by maintaining atomicity, consistency, isolation, and durability. Atomicity is achieved through protocols like the Two-Phase Commit (2PC), which ensures that all transaction components succeed or fail as a unit. Consistency is upheld by consensus algorithms such as Paxos or Raft, ensuring all nodes agree on data states. Isolation is maintained via locking mechanisms and timestamp ordering to manage concurrent transactions safely. Durability is ensured through data replication and write-ahead logging, which guarantees that completed transactions persist in the face of failures .

Ensuring ACID compliance in distributed databases faces challenges like network latencies affecting isolation, difficulty in maintaining consistency across partitions, and overhead from protocols like Two-Phase Commit, which can cause blocking and introduce single points of failure. Durability requires robust mechanisms for data replication to prevent data loss during failures. These complexities demand sophisticated algorithms and infrastructural support, potentially increasing system cost and complexity while balancing trade-offs between consistency and availability .

Query optimization significantly impacts database management by reducing query execution time and resource usage, essential for efficient data processing. Machine learning contributes by analyzing query execution patterns to develop optimized execution plans, automating index creation based on access trends, and suggesting improvements. This reduces manual intervention, allowing dynamic adaptation to workloads and enhancing query performance even as data environments evolve .

Data minimization, a key GDPR principle, dictates collecting only essential data, impacting database design by necessitating efficient storage structures and streamlined data processes. This reduces risks of breaches, enhances operational efficiency, and requires databases to be designed for flexible data management that can adapt to changing data requirements. By minimizing unnecessary data retention, organizations not only comply with legal mandates but also optimize storage and processing resources, fostering sustainable data practices .

The Two-Phase Commit (2PC) protocol is crucial for maintaining data consistency in distributed systems. It involves a Prepare Phase, where a coordinator requests all participant nodes to prepare for commit, and a Commit Phase, where, based on participants' unanimous commit votes, the coordinator sends a commit or abort command. This ensures atomicity and consistency, though it introduces challenges like blocking if nodes fail. 2PC is significant as it guarantees all parts of a transaction are completed reliably across systems .

You might also like