Handling complex computation on a web app involving data from a database - sql

Just some background.
This question is to help my team and I make a decision on how to handle an app we are working on. Currently the application is hosted locally in ASP.NET C# and the complex calculations that are done are handled in SQL as a stored procedure. The data is pulled into queries and the server will handle all the calculations and return a recordset which is written to a table and the front end can access that table.
So moving forward, we're thinking of moving the application to the web with Django and deciding how to handle the server side of things. So what we really wanted to understand is, how do others handle situations like these? Do we continue with the same idea and build a SQL server and do the same thing or is there a better way to solve this problem? We want to the user to be able to kick the calculations off and do other things while it runs in the background. The user shouldn't have to sit on the page because these calculation can take an hour or more depending on the complexity. We'd appreciate the thought and ideas.
Thank you so much.

That is exactly what Celery does. And the integration with Django is very easy. Read about it.

Related

Looking for advice on appointment scheduling process

I'm the SQL Server developer working with a small team on an appointment scheduling project where the client is insisting on having the business logic and processes reside at the database level. I've tried using functions, stored procedures and triggers to handle the processing, but things aren't working out.
Three different external applications are being used: voice, where calls are taken, agents who enter and request appointment dates and times and a web site where users request an appointment. There are huge timing synchronization issues.
My feeling is that the business processes for scheduling should be developed in a separate module that sits between the database and the external applications.
Looking for advice from anyone who has worked on an appointment scheduling system that involves multiple front end apps and a single back end database. Any help would be much appreciated. Thanks in advance.
I'm the SQL Server developer working with a small team on an
appointment scheduling project where the client is insisting on having
the business logic and processes reside at the database level.
It is unusual for a client to have an opinion about how problems are solved. Normally a client/customer only thinks about the what and the team thinks about the how.
Unless the client is somewhat technical and has a reason why he thinks it should all be done in the database. In this case I would discuss those reasons because they might already be an interpretation of his own problem and is possibly asking the wrong question.
I would create one web application and have the phone operators, agents and web users use the same application (maybe with different rights depending on the role). This way you only have to create one application build with a single code base.

Ho do I call a web service on a database change?

There is a business process that happens currently in a totally manual fashion, which seems to me to be a no-brainer to automate. Basically what happens is when a new row is added to a single table in a SQL server, a person then manually makes a change in another business system (based on some very simple business logic).
It's easy to capture the business logic and make the change in the 2nd system programmatically using a web-service. However I don't know how to trigger the calling of the web service when the new row is added into the SQL table.
I've been reading from older forums posts that there are 2 options - the SQL dependency class in .NET and a database trigger in SQL. I was wondering if those are still the 2 main options for a problem like this one.
A colleague of mine showed me the SignalR framework and it was very impressive, but I understand that only works for web applications with a HTML/Javascript front end? I was wondering if there was something similar to that, that's easy to use to simply call a webservice.
Thanks
You can use sql dependency and you'll be notified each time your database changes
I wrote a tutorial a few years back on how to deal with this
Sql Dependency tutorial

How to model data flows with a SQL backend?

My question is not about a specific code. I am trying to automate a business data governance data flow using a SQL backend. I have put a lot of time searching the internet or reaching out people for the right direction, but unfortunately I have not yet found something promising so I have a lot of hope I would find some people here to save from a big headache.
Assume that we have a flow (semi static/dynamic flow) for our business process. We have different departments owning portions of data. we need to take different actions during the flow such as data entry, data validation, data exportation, approvals, rejections, notes etc and also automatically define deadlines, create reports of overdue tasks and people accountable for them etc.
I guess the data management part would not be extremely difficult, but how to write an application (codes) to run the flow (workflow engine) is where I struggle. Should I use triggers or should I choose to write codes to frequently run queries to push the completed steps to next step, how I can use SQL tables to keep the track of flow etc
If one could give me some hints on this matter, I would be greatly appreciated
I would suggest using the sql server integration services SSIS, you can easily mange the scripts and workflow based on some lookup selections, and also you can schedule SSIS package on timely bases to trigger and do the job.
It's hard task to implement application server on sql server. Also it's will be very vendor depended solution. Best way i think to use sql server as data storage and some application server for business logic over data storage.

Querying multiple database servers?

I am working on a database for a monitoring application, and I got all the business logic sorted out. It's all well and good, but one of the requirements is that the monitoring data is to be completely stand-alone.
I'm using a local database on my web-server to do some event handling and caching notifications. Since there is one event row per system on my monitor database, it's easy to just get the id and query the monitoring data if needed, and since this is something only my web server uses, integrity can be enforced externally. Querying is not an issue either, as all the relationships are one-to-one so it's very straight forward.
My problem comes with user administration. My original plan had it on yet another database (to meet the requirement of leaving the monitoring database alone), but I don't think I was thinking straight when I thought of that. I can get all the ids of the systems a user has access to easily enough, but how then can I efficiently pass that to a query on the other database? Is there a solution for this? Making a chain of ors seems like an ugly and buggy solution.
I assume this kind of problem isn't that uncommon? What do most developers do when they have to integrate different database servers? In any case, I am leaning towards just talking my employer into putting user administration data in the same database, but I want to know if this kind of thing can be done.
There are a few ways to accomplish what you are after:
Use concepts like linked servers (SQL Server - http://msdn.microsoft.com/en-us/library/ms188279.aspx)
Individual connection strings within your front end driving the database layer
Use things like replication to duplicate the data
Also, the concept of multiple databases on a single database server instance seems like it would not be violating your business requirements, and I investigate that as a starting point, with the details you have given.

What is the fastest way for me to take a query and turn it into a refreshable graph of the results set?

I often find myself writing one off queries to either answer someone's question or trouble shoot something and I would like to be able to quickly expose the on demand refreshable results of the query graphically so that I can share these results to others without having to go through the process of creating an SSRS report and publishing it to a reporting services server.
I have thought about using excel to do this or maybe running a local SSRS server but both of these options are still labor intensive and I cannot justify the time it would take to do these since no one has officially requested that I turn this data into a report.
The way I see it the business I work for has invested money in me creating these queries that often return potentially useful data that other people in the organization might want but since it isn't exposed in any way and I don't know that this data is something they want and they may not even realize they want this data, the potential value of the query is not realized. I want to increase the company's return on investment on all these one off queries that I and other developers write by exposing their results graphically so that they can be browsed by others and then potentially turned into more formalized SSRS reports if they provide enough value to justify the development of the report.
What is the fastest way for me to take a query and turn it into a refreshable graph of the results set?
Why dont you simply use what you may already have. Excel...you can import data via an ODBC / Oracle / SQL Connection. Get Data..and bam you can run the query and format it right in the spreadsheet and provide sorting etc. All you need to supply is the database name and user name and password to connect to the db.
JonH is right regarding Excel's built in ODBC support, but I have had tons of trouble with this. In my case, the ODBC connection required the client software to be installed so that it could use the encryption methods, etc. Also, even if that were not the case, the user (I believe) would still have to manually install and set up an ODBC connection.
Now if you just want something on your machine to do the queries and refresh them, JohH's solution is great and my caveats are probably irrelavent. But if you want other users to have access, you should consider having a middle-man app (basically a PHP script, assuming a web server is an option for you), that does a query, transforms the results into XML, and outputs it as "report-xyz.xml". You can then point anybody running a newer version of Excel to that address and they can very easily import the data into Excel with no overhead. (basically a kind of web service).
Keep in mind, I don't think you should have a web script that will allow users to make queries to your Database server! You would have some admin page where you make pass the query in and a new xml file with the results gets made. So my idea is also based on the idea that you want to run the same queries over and over without any specifics passed in. (if that were the case, I'd look into just finding a pre-built web services bridge for your database that already has security features built in. Then you could have users make the limited changes allowed.)