views:

246

answers:

8

After much reading on ruby on rails and multiple database connections, it seems that I have found something that not that many folks do, at least not with ror. I am used to querying many different databases and schemas and pulling back the information either for a report or for one seamless page. So, a user doesn't have to log on to several different systems. I can create a page that has all the systems on one or two web pages.

Is that not a normal occurrence in the web and database driven design?

EDIT: Is this because most all my original code is in classic asp?

A: 

Pulling data from two databases and compiling a report is not uncommon, but because cross-database queries cannot be optimized by the query engine of either database, OLTP systems typically use a single database, to keep the application performant.

Robert Harvey
+1  A: 

It is not uncommon to hit multiple databases during a single part of an application's workflow. However, in every instance that I have done it, this has been performed through several web service calls, which among other things wrap the databases in question.

I have not, to my knowledge, ever had a need to hit multiple databases directly at once and merge results into a single report.

Dusda
wow. I cannot imagine not doing that.
johnny
I do this. An authentication service uses one db and is accessed by an application that uses another db. +1 But I try to avoid accessing two databases directly from the same application. It's a pretty good indicator that some refactoring needs to be considered.
Spencer Ruport
@johnny How come? It's pretty common (at least in .NET development) to wrap data layers in in a web service anyway, if for no other reason than clear separation of tiers (and with TCP or Pipes endpoints, the performance hit is arguably negligible).
Dusda
I typically either issue a SQL statement in code behind or create a table adapter using ODBC for a particular piece of data.
johnny
If you are using Web services to create a SOA, CRUDy Interfaces are often seen as an anti pattern- http://msdn.microsoft.com/en-us/library/ms954638.aspx scroll to "Anti-Pattern #1'
RichardOD
+2  A: 

Our client website runs across 3 databases, so I do this to. Actually, I'm condensing everything into views off of one central database which then connects to the others.

I never considered this to be "normal" behavior though. I would guess that most of the time you would be designing for one system and working against that.

EDIT: Just to elaborate, we use Linq to SQL for our data layer and we define the objects against the database views. This way we keep reports and application code working off the same data model. There is some extra work setting up the Linq entities, because you have to manually define primary keys and set up associations... however so far it has definitely proven worthwhile. We tried to do so with Entity Framework, but had a lot of trouble getting the relationships set up appropriately and had to give up. The funny thing is I had thought Entity Framework was supposed to be designed for more advanced scenarios like ours...

Telos
A: 

With ORM's it may be a little difficult. However, it can be done. Pull the objects as needed from the various databases, then use them as a composite to create a new object that is the actual one that is desired. If you can skip the ORM part of the process, then you can directly query the databases and build your object directly.

Joe
+1  A: 

I've seen this kind of architecture in corporate Portals- where lots of data is pulled in via different data sources. The whole point of a portal is to bring silo'd systems together- users might not want to be using lots of systems in isolation (especially if they have to sign into each one). In that sort of scenario it is normal, particularly if it is a large company that has expanded rapidly and has a large number of heterogenous systems.

In your case whether this is the right thing to do depends on why you have these seperate DBs.

RichardOD
I have them for the reasons you specified. Lots of different systems and nobody talks or cares if they can. It is up to me or someone else to present the data. For me in the past it was non-mvc, classic or .net asp, odbc, sql statements (via table adapter.). It does not appear, yet, to be that simple with ror.
johnny
If you read about WebSphere Portal- you will probably see you are achieving some of the functionality products like this enable- http://www.ibm.com/developerworks/websphere/zones/portal/newto/ (I am not suggesting you switch to WebSphere Portal, merely using it as an example of an aggregator of Enterprise Resources).
RichardOD
Thanks. I am aware of it but did not want to use it. It costs big bucks and the learning curve seemed very high. It probably is the right fit but I can't use it right now.
johnny
I used it. It cost a lot, was slow, painful and you needed a very fast machine just to develop with the tools provided. I would stick with what you are using. The article link was just to show why you might connect to various data sources. The product was a scandal in Italy- you can read about it here- http://italianscandal.wordpress.com/page/2/
RichardOD
A: 

If you build the system from the ground up, it is not advisable to do it this way. If you are working with a system you didn't design, there is no much choice and it is not uncommon (that is the difference between "organic" and "planned" grow).

BlogueroConnor
+2  A: 

I really honestly think that most ORM designers don't seem to take the thought that users may want to access more than one database into account. This seems to be a pretty common limitation in the ORM universe.

Jason Baker
That seems very limiting and dissappointing.
johnny
A: 

Not counting master and various test instances, I hit nine databases on a regular basis. Yes, I inherited it, and yes, "Classic" ASP figures prominently. Of course, all the "brillant" designers of this mess are long gone. We're replacing it with things more sane as quickly as we safely can.

I would think that if you're building a new system, and keep adding databases and get to the point of two or three databases, it's probably time to re-think your design. OTOH, if you're aggregating data from multiple, disparate systems, then, no, it's not that strange. Depending on the timliness you need, and your budget for throwing hardware at the problem, and if your data is mostly static, this would be a good scenario for a "reporting server" that pulls the data down from the Live server periodically.

Adrien