SQL interface to data?

In computer science classes we're taught to "Program to an interface, not an implementation."

If we want to fetch some data, we ask the interface for the data, and the interface then translates that and fetches the data for us.

That way we can modify where the data is actually stored, and we just have to alter the interface, rather than track down every line of code which fetches that piece of data.

Is there an equivalent idea in SQL?

Currently I'm seeing SQL code that pulls data directly from the database, specifying the exact database name, table, and column.

Is there a way to insert an interface in SQL so SQL code queries an "SQL interface" which in turn directs to the actual data? Or is that just not practical for efficiency reasons?
deleydSoftware EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Data DudeCommented:
Let us know when you have an actionable question for us, as what I see for far is alot of jargon with very little specifics.
Kyle AbrahamsSenior .Net DeveloperCommented:
Think of it like a funnel.  

On the top (widest) you have your implementation(s).  Those can be on multiple devices, across different platforms (web application, windows application, web services, and a mobile app let's say).

So rather than controlling the code that access the data for each, you publish an interface.  (This is the middle part).  Each platform then accesses the interface whose job it's responsible for setting and retrieving data.

The interface then talks to SQL, which has the different tables and columns.  (the narrowest part of the funnel)

I guess if you really wanted to consider database interfaces you could have views and stored procedures.  EG:  Restrict access to the underlying tables, get all data via views/stored procedures and all sets via stored procs.

In that way you could potentially have multiple applications using the same db code . . . but it's sort of redundant as you should already have the middleware software interface if that makes sense.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave BaldwinFixer of ProblemsCommented:
Glad I didn't take any computer science classes.  For what it's worth, you do have to go thru the driver and not directly to the database.  If you want to put an "interface" in front of that you can.
deleydSoftware EngineerAuthor Commented:
I guess it's not possible. SQL queries pull from the database, not from an interface.

Which means we can't update our database design because there's a ton of SQL query code already written that assumes the database is arranged the way it is now that would all have to be changed.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.