SQL Stored Procedures as Front End?

  • Thread starter WWGD
  • Start date
  • Tags
    sql
In summary, the conversation discusses the use of SQL stored procedures as a front end and compares it to an Access front end. The speaker mentions the benefits of using stored procedures, such as performance, security, encapsulation, and code reuse, but also acknowledges that it may not be necessary for simple queries. The alternative of using Object Relational Mapping (ORM) is also mentioned, highlighting its benefits such as rapid app development, less code to be written, and good maintainability. However, there are also counter-arguments for ORMs, such as lower performance and less security. The speaker concludes that the decision to use stored procedures or ORM depends on the specific situation and their personal experience.
  • #1
WWGD
Science Advisor
Gold Member
7,006
10,459
Hi,
Just curious: is it possible/feasible to use SQL stored procedures as a front end? I mean, couldn't we
design stored procedures to allow for easier querying if we knew the general type of queries that would be used for the application (of course, the application for which we designed the back-end SQL) ?
 
Technology news on Phys.org
  • #2
I believe that you can do that but it's been a while since I've done it. I'll have to dig around for an example if you want one.
 
  • Like
Likes WWGD
  • #3
Borg said:
I believe that you can do that but it's been a while since I've done it. I'll have to dig around for an example if you want one.
Thanks^5000 (for previous) Borg. How does this compare to an Access front end in general?
 
  • Like
Likes Borg
  • #4
WWGD said:
Thanks^5000 (for previous) Borg. How does this compare to an Access front end in general?
I don't know about Access. I remember seeing a trick like this in an Oracle database about four years ago. If I remember correctly, it's an Oracle View.
 
  • Like
Likes WWGD
  • #5
You can use stored procedures - I've used them a lot, to talk in my own experience, as they have four crucial benefits: performance - the compilation is done on database server, so subsequent requests have performance gain, security - stored procedures are database objects, so you can take security measures and prevent some nasty things to happen, like SQL injection attacks, encapsulation - talking essentially about business logic in one place and of course last but not least, code reuse. However, stored procedures design and implementation is waste of time if simple queries is the case. That's because code must be written in the application to call the stored procedure, pass the parameters it should, check the result and return data.
A more preferred way is Object Relational Mapping, as ORM essentially creates a representation of the data model. So effectively you can access your database without SQL code or constructs. Especially for CRUD operations that represent a very high percentage of total operations to be executed, ORMs create parameterized queries automatically.
In general, ORMs have more benefits in many cases than stored procedures, like rapid app development, less code to be written, good maintainability, performance and they don't break the N-Tier model - something that stored procedures do.
Of course there are counter - arguments for them too, as lower performance than stored procedures, much overhead, less security and others, which in most cases are of minimum impact.
In my opinion the situation at hand is the best judge about what to use and how. In my experience, after ORM became widespread, I tend to use it more and use stored procedures for more "special" reasons. Such reasons include: big number of records pushed in a single statement, legacy applications (that you can't but use them), some complex query situations and data aggregation.
 
  • Like
Likes WWGD

1. What is a SQL stored procedure?

A SQL stored procedure is a set of SQL statements that are saved and can be called upon to perform a specific task. It is similar to a function in other programming languages, and it can be used to simplify and streamline complex database operations.

2. How can SQL stored procedures be used as a front end?

SQL stored procedures can be used as a front end by acting as a middleman between the user interface and the database. They can receive input from the user interface, process it using SQL statements, and then return the results to the user interface. This allows for a more efficient and secure way to interact with the database.

3. What are the advantages of using SQL stored procedures as a front end?

There are several advantages to using SQL stored procedures as a front end. They can improve performance by reducing the amount of data that needs to be transferred between the application and the database. They also provide an extra layer of security as they can restrict access to the database and prevent SQL injection attacks. Additionally, using stored procedures can simplify the application code and make it easier to maintain.

4. Are there any disadvantages to using SQL stored procedures as a front end?

One potential disadvantage of using SQL stored procedures as a front end is that they can be more difficult to debug and troubleshoot compared to traditional application code. They also require a certain level of SQL knowledge and may not be suitable for all developers. Additionally, making changes to a stored procedure can be more time-consuming and may require more advanced database permissions.

5. Can SQL stored procedures be used with any type of database?

Yes, SQL stored procedures can be used with most modern databases, including Microsoft SQL Server, Oracle, MySQL, and PostgreSQL. However, the syntax and features may vary slightly between different databases, so it is important to be familiar with the specific database you are working with.

Similar threads

  • Programming and Computer Science
Replies
18
Views
3K
  • STEM Academic Advising
Replies
1
Views
679
  • Computing and Technology
Replies
9
Views
3K
  • Set Theory, Logic, Probability, Statistics
2
Replies
35
Views
2K
  • Programming and Computer Science
Replies
15
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
3K
Replies
5
Views
2K
  • Programming and Computer Science
Replies
7
Views
3K
  • Programming and Computer Science
Replies
11
Views
992
  • Programming and Computer Science
Replies
22
Views
919
Back
Top