Database Unit 7
Database Unit 7
CS 2203 – Databases
Term 1 - 2025
University of The People
a) Importance of Transactions
Transactions are essential for maintaining data integrity and consistency within an online
marketplace platform. They ensure that all operations related to a single logical unit of work are
completed successfully before the changes are committed to the database. This is particularly
important in critical operations such as processing orders and updating inventory levels.
For example, when a user places an order, multiple actions must occur: the order must be
recorded, the inventory must be updated to reflect the purchased items, and the payment must be
processed. Using transactions allows us to group these actions into a single unit. If any part of
this process fails—such as insufficient inventory or a payment error—the entire transaction can
be rolled back, ensuring that the database remains in a consistent state. This prevents issues like
To implement this, I would use SQL commands like BEGIN TRANSACTION, COMMIT,
Sql
BEGIN TRANSACTION;
COMMIT;
ELSE
ROLLBACK;
END IF;
This ensures that either all changes are applied or none at all, thereby preserving data integrity.
In the context of the online marketplace platform, different types of SQL play distinct roles:
Static SQL: These are predefined SQL statements that do not change at runtime. They
are typically used for operations that require consistent queries, such as retrieving product
compile time.
Dynamic SQL: This type allows for more flexibility as SQL statements can be
constructed at runtime based on user input or other variables. For example, users may
search for products using various criteria (e.g., category, price range). Dynamic SQL
enables the application to build these queries on-the-fly, accommodating various search
parameters.
Embedded SQL: This involves integrating SQL statements directly within application
code (e.g., Java or C#). It allows developers to write SQL commands alongside
programming logic, facilitating seamless interaction between the application and the
database. For instance, when processing user registrations or login attempts, embedded
Each type of SQL contributes to executing database operations effectively while catering to
To establish connections with the database for the online marketplace platform, I would utilize
both JDBC (Java Database Connectivity) and ODBC (Open Database Connectivity):
JDBC: This is a Java-based API that allows Java applications to interact with databases.
It provides methods for querying and updating data in a database. To connect to the
database using JDBC, I would load the appropriate driver and establish a connection as
follows:
java
"username", "password");
Using JDBC enables seamless integration of database operations within Java applications,
ODBC: This is a standard API for accessing database management systems (DBMS). It
SQLHENV henv;
SQLHDBC hdbc;
SQL_NTS);
Using ODBC allows for broader compatibility across different programming environments while
Conclusion
In summary, transactions play a vital role in ensuring data integrity within an online marketplace
platform by allowing grouped operations that can be committed or rolled back as needed. The
use of static, dynamic, and embedded SQL enhances operational efficiency by catering to
various application needs. Additionally, leveraging JDBC and ODBC facilitates seamless
contribute to building a robust and scalable online marketplace platform capable of handling
Date, C. J., & Darwen, H. (2006). Database Design and Relational Theory: Normal
Pearson.
GeeksforGeeks. (2022). Difference between Static SQL and Dynamic SQL. Retrieved
from https://www.geeksforgeeks.org/difference-static-dynamic-sql/