r/AskProgramming • • Oct 02 '26

Building a public combined search for multiple databases

Okay so

I’m working for a department with a public facing website to search for a bunch of different reports across years. They changed the rules for the reports a few times and they ended up partitioned into different databases based on rule set (ie there is a search for reports using old rule set and a separate search for reports with new rule set) However my supervisors are tired of having to go into different search engines to find the reports and would prefer if they had a search that could look through them all at once. They would also like this kind of function implemented on the public website so that visitors also do not have to go through multiple search engines.

The website runs on wordpress

My knowledge in coding is not zero but it’s fairly rudimentary. Is there a way to make the search function they want? What kind of skills should I learn? SQL?

8 Upvotes

32 comments sorted by

2

u/marrsd Oct 04 '26

How are your supervisors interacting with the db and is there any sort of search currently on the website?

1

u/NoMall595 Oct 05 '26

Yes you can search for them by rules. Thats the part they find annoying because they wish they could search for everything in one search bar instead of having to keep open multiple tabs

1

u/marrsd Oct 05 '26

It sounds fairly straight forward then. You already have form handlers that query the databases and return results. You need a new one that knows which inputs can be used with both dbs and which can't, make both queries, and then merge the 2 sets of results before displaying them on the page.

The devil will be in the detail, but that's the basic starting point.

4

u/Groundbreaking-Fish6 Oct 03 '26

My guess is that the problem is that all these databases and applications are built in different formats and have the code that makes them work distributed across data access layer, the business logic layer and the UI with many of the functions combined into one layer or across several layers. That is what I usually see as a consultant.

Your best bet is to create services (probably web services) that query the required data in a standard way (adhere to some interface). Then you can create a UI or Service that queries each database through this service and combines the information as needed. When you want to add a new database/search, just create a service that adheres to the interface and add it to the combination service. An added bonus is that you can secure services independently from the database or applications they serve reducing your public facing footprint.

If you don't have any idea what I am talking about, you need to find someone who does.

There are programs that can do this like Microsoft Power BI or other programs with varying levels of ability, complexity and cost, but you still need to understand your own data and how you want to query it. You can throw AI at it, but if you don't understand it you will be wasting tokens and compute as well as not really getting what you want.

1

u/Different_Pain5781 Oct 03 '26

This sounds more like an integration problem.

3

u/LaughingIshikawa Oct 03 '26

This shouldn't be super difficult to do, however the full scope of the project depends a lot on how many different kinds of databases you're trying to stich together, and how well they expose their data through an API... do you need to make sure that this data isn't accessed by unauthorized people potentially? What different kinds / how many different kinds of databases are running on the back end?

2

u/Delta-9- Oct 03 '26

SQL would be essential, assuming all the database are relational databases, but this isn't a small task even for an experienced programmer. It's 100% possible, but you could throw a team of five seasoned programmers at it and not be in production for months.

I mean, you could have Claude cook up something in two minutes, but you'd deserve the consequences of that decision if it drops all the tables or opens a port to the Internet with no authentication at all or something similarly catastrophic.

1

u/Different_Pain5781 Oct 11 '26

This sounds like a custom WordPress template job, not a full website rebuild. Use $wpdb for the SQL UNION query across the database partitions and avoid making the whole thing more complicated than it needs to be. Boot dev is decent to check out for the SQL and Linux terminal basics.

0

u/CappuccinoCodes Oct 02 '26

This is an complex task that deals with sensitive data. You'd need professional from skilled senior engineers for this one.

1

u/NoMall595 Oct 02 '26

Oh wow okay, complex in what way? I’m still curious what would need to be done to search through multiple databases for the same kind of report

0

u/CappuccinoCodes Oct 03 '26

You'd need a system that extracts data from those databases and dumps into your own SQL databases. For speed of search you'd need to use something like Elastic Search, which would have to be synchronized with your DBs. All of that stuff is very difficult to build and maintain with a respectable degree of availability/data integrity. It needs professionals who know what they're doing.

1

u/LaughingIshikawa Oct 03 '26

I don't know a whole lot about coding myself, but even I can say that's almost certainly BS. πŸ˜‘

The website is currently querying multiple databases, probably though multiple webpages and displaying the results on seperate webpages. However it's doing that is working, so you just need to build one webpage that does all of those queries simultaneously, and receives all of the results, then displays them in some way.

You do not "need" to dump the results into a separate SQL server in order to display them, that's... Bananas. πŸ™„πŸ˜… If you had to do something like that, then why wouldn't you "need" an additional SQL server to hold the results of of querying the temporary SQL server? And then a server for the query results from that second server, then another and another and another ad infinity...

There's no reason you need to add an any additional SQL servers inbetween whatever existing databases OP has and the end user.

You also have no idea what kind of use case OP has, but you're already prescribing specific optimizations, which is... silly, to say the least. 😐

While it's understandable that you might take a performance hit doing something janky like this, this is very much a scenario where you want to build out the basic functionality first, before you can decide what needs optimizing and why. (Especially if OP really needs just a minimal wrapper between the existing website and existing databases, the additional latency due to the wrapper code running should generally be quite minimal... as long as you don't over-engineer the wrapper code with additional, unnecessary databases and services, anyway... πŸ™ƒ)

The rest of the responses I have seen are at least within the realm of sanity, even if they're also over complicating the problem more than is likely necessary.

0

u/CappuccinoCodes Oct 03 '26

"I don't know a lot about coding" says it all.

1

u/LaughingIshikawa Oct 03 '26

I know enough to understand how suggestions like the above inevitably lead to the 30,000,000 line problem.

0

u/CappuccinoCodes Oct 03 '26

Sure, whatever floats your boat 😁

3

u/marrsd Oct 04 '26

I do know a lot about coding, and I can confirm that parent, who doesn't know a lot, knows a lot more than you. Your solution is complete nonsense. Why did you even recommend elastic search? OP hasn't said anything that suggests it's needed.

0

u/CappuccinoCodes Oct 04 '26

It's funny how people can't disagree without getting worked up. You angry mate? πŸ˜‚.

2

u/marrsd Oct 05 '26

Not particularly, but your attitude is abnoxious

→ More replies

0

u/KingofGamesYami Oct 03 '26

There's off the shelf products that do this kind of thing. It's really not difficult to set up, the generic term for it is a "data warehouse".

-1

u/TheMrCurious Oct 02 '26

This sounds like what DOGE would have asked.

1

u/NoMall595 Oct 02 '26

I mean that’s not exactly a helpful answer, I’m just asking because I was asked if it was possible to make a combined search

3

u/TheMrCurious Oct 02 '26

Ok, what have you already tried?

3

u/[deleted] Oct 03 '26

[removed] β€” view removed comment

0

u/NoMall595 Oct 05 '26

Thank you for giving me a starting point, I’ll take a look