List the three main approaches to database programming.
What are the advantages and disadvantages of each approach?
If you are starting to learn about databases and programming for them, you might be wondering what the best approach is.
There are many ways to access a database but each one has pros and cons.
This article will help you decide which approach works best for your situation by comparing three main approaches:
Three main approaches to database programming:
Database programming is a type of programming, which uses databases to store and retrieve data.
There are three main approaches to database programming:
Structured Query Language (SQL) is a language used by programmers to access data in relational databases.
SQL can be used to create tables containing information about the contents of those databases, such as names, addresses, phone numbers and so on.
It also allows you to retrieve specific rows within these tables by specifying criteria like “find all people whose name begins with ‘N’” or “find all customers who bought more than $100 worth of goods within the last six months”.
This method allows us great flexibility when it comes time for us “to get our hands dirty”
1. Using the database-specific APIs provided by database vendors, such as Oracle’s JDBC and ODBC drivers, Microsoft’s ADO.NET, and so on.
The first approach is to use the database-specific APIs provided by database vendors, such as Oracle’s JDBC and ODBC drivers.
This approach provides a unified way to access data from multiple databases and can be used to access data from a single database using multiple languages.
In addition, this approach can also be used when you want to access the same table in multiple languages at the same time (for example, if it’s an application written in C++).
2. Using a vendor-independent API or APIs that supports multiple database products with a common interface, such as JDBC and ADO.NET.
How to code against a database is one of the most important decisions you will make when developing an application.
You have to choose between two approaches:
- Using a vendor-independent API or APIs that supports multiple database products with a common interface, such as JDBC and ADO.NET; or
- Using an API that is vendor-specific and therefore tied to a specific database product (e.g., Oracle).
3. Using data access objects (DAOs). This is the most flexible approach and is independent of specific databases and their APIs
If you’re using a legacy database and don’t have access to the source code, then you’ll have to use DAOs. A DAO is a simple Java class that encapsulates the details of accessing a database.
This means that it hides all of the complexity of accessing the database from other classes in your application, which makes it easier to reuse across applications.
But if you do have access to source code, then there’s another option: writing your own custom stored procedure or function instead—something we’ll explore later on in this article series!
Conclusion
This essay has covered the three main approaches to database programming.
We’ve looked at how you can use vendor-specific APIs and a common interface, as well as data access objects (DAOs).
References
Troussas, C., Krouska, A., & Sgouropoulou, C. (2022). Double-Layer Controller for Detecting Learners’ Erroneous Knowledge in Database Programming. In International Conference on Intelligent Tutoring Systems (pp. 204-212). Springer, Cham.
Sarcar, V. (2020). Database Programming. In Getting Started with Advanced C# (pp. 283-339). Apress, Berkeley, CA.