Programming Assignment Unit 7
Programming Assignment Unit 7
CS 2203-01 - Databases 1
Lutalo Martin
SQL transactions, how to execute SQL, and database connection specifications such as JDBC and
Transactions provide a necessary layer of data integrity and consistency when it comes to the
online market place, especially when performing critical operations such as processing orders or
tracking inventory updates. A transaction will take several database operations and group them
together as a single atomic unit which will either commit all changes all together or roll all
changes back if a part of the transaction fails (see Datacamp, 2024; Zanini, 2023). This atomicity
ensures that partial updates don't occur to keep things consistent. For example, an update that
deducts from an inventory count without recording a corresponding order could lead to
In practice, a user makes an order (or purchase), and the system needs to update the order table,
update inventory levels, and possibly update the user transaction history. Perform all of these
changes in a transaction. With a transaction, all of the changes are either successful, or they fail. If
anything fails (e.g., the payment processor returns an error), the transaction will roll back, and
database consistency is maintained. If not managed properly, the user may sell products they do
not have because of inconsistencies in the database, or worse, possibility of orphan orders
(Pingcap, 2023).
The properties of ACID (Atomicity, Consistency, Isolation, and Durability) define how a
transaction should behave in order for the processing to be considered reliable (Vidhya et al.,
2016). For instance, isolation guarantees that concurrent transactions do not interfere (e.g., if two
users try to complete an order at the same time ensure one transaction will win while the other will
Static SQL represents SQL statements predetermined at compile-time. Static SQL is the fastest
and the most secure option, given that the database will pre-compile and optimize execution plans
for executing static SQL. Typical operations of getting product listings or user profiles of users as
a static SQL execution is ideal due to the known inputs of the operation (IBM, 2021).
Dynamic SQL is those constructed and executed at runtime. Dynamic SQL is used as a way to be
flexible and run a SQL query dependent on a user or variable condition. An example where
dynamic SQL was required was when users in the marketplace were applying search filters having
variable parameters, where the application required one of the search filters as one of the
parameters to dynamically build a SQL query based on the user input, thus not knowing what filter
query was returned until runtime. While dynamic SQL offers flexibility to the initial development,
one needs to be cautious about performance impacts; also consider using logic to prevent an SQL
Embedded SQL is SQL statements that are written as a terminal for a host SGML supplied in
languages such as Java or C. Embedded SQL allows developers to fluidly apply business logic to
database data as a typographical similarity to program code. The inclusion of variables to pass
information from a program to SQL is called Special Query Language Host Variables. Special
Query Language Host Variables provided an efficient way to manipulate data from the business
Within the context of the created online marketplace, embedded SQL allowed the application to
run database commands as the business logic of a module, and static and dynamic SQL to cater for
JDBC (Java Database Connectivity) is the standard Java API to connect and issue queries to
relational databases. JDBC standardizes how to interact with multiple different databases through
JDBC drivers. In our marketplace platform, the Java-based backend service uses JDBC to
interface connections to the database, execute SQL statements, and process result sets (Baeldung,
n.d.).
JDBC allows the application to use connection pools, enabling multiple concurrent connections to
the database, thereby allowing the application to scale. Prepared statements will limit SQL
injection and improve performance through pre-compilation of the SQL and parameters.
programming interface (API) that allows application access to various database management
systems via a common interface. JDBC is more commonplace for Java applications, while ODBC
can be used in varying environments or when interacting with legacy systems, provided that the
tight integration with Java. ODBC may be used when support for interoperating with other
Conclusion
By utilizing ACID compliance for transactions, data integrity is ensured when processing
important operations such as the processing of an order. In addition, deciding to use static,
dynamic, and embedded SQL based on the application requirements will achieve the best
compromise of performance and flexibility for database operations. Incorporating JDBC and
ODBC will facilitate a solid, scalable connection between the application and database systems as
https://www.datacamp.com/tutorial/sql-transactions
IBM Data Server Client Packages. (2021, March 8). Designing static and dynamic SQL statement
topic=designing-static-dynamic-sql-statement-execution-in-embedded-sql-applications
https://insightsoftware.com/blog/what-is-odbc/
https://www.pingcap.com/article/understanding-sql-transactions-for-data-integrity/
Vidhya, V., Jeyaram, G., & Ishwarya, K. (2016). Database management systems. Alpha Science
International.
Zanini, A. (2023, February 14). Database transactions 101: The essential guide. DbVisualizer.
https://www.dbvis.com/thetable/database-transactions-101-the-essential-guide/
https://www.geeksforgeeks.org/transaction-in-dbms/
GeeksforGeeks. (2022, November 9). Difference between Static and Dynamic SQL.
GeeksforGeeks. https://www.geeksforgeeks.org/difference-static-dynamic-sql/
https://www.geeksforgeeks.org/establishing-jdbc-connection-in-java/
Patel, D. (2023, December 17). Understanding ODBC and JDBC: A Beginner’s guide to database
a-beginners-guide-to-database-connectivity-44d92b22eab6