473,796 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looking for minimal SQL


Hi

I would like to develop an app that is (more or less) database independet.
Python DB API helps when masking "parameters " of sql statements. The db
driver cares for the correct conversion of a date, text, etc. This already
is a big step into the right direction.

The next step would be to use the least common denominator of all sql
dialects and do without all the sql goodies that the dialects offer... and
for this part I am wondering if anyone has a link / hint / book that
assembled this minimum sql. I am looking for something that says for
example:

Table/DB Design: always use lowercase letters, ...

Allowed sql functions: min, max, count

WHERE / HAVING hints:
- Don't use subselects

The focus is actually limited to SELECT / INSERT / UPDATE / DELETE (I
don't think that GRANT / CREATE XXX / ... statements are very portable).

I am aware, that a solution created this way is not as fast and as elegant
as an app that uses all features of a dialect, but I am really looking for
something database independent...

Thanks for any hints,
Marco

Jul 18 '05
14 1726
Dennis Lee Bieber <wl*****@ix.net com.com> wrote:
On Thu, 01 Jul 2004 12:42:28 +0200, Marco Aschwanden
<PP**********@ spammotel.com> declaimed the following in
comp.lang.pyth on:
easiest way to go. For example: If Sub-Selects are not portable than I

"If"??? I think they are still on the TBD list for MySQL, so at
the moment it is not an "if", it is an "as". <G>


They've been available since at least 4.1.0. Not always working
correctly, mind, but they've been there. In fact, I've hit
problems running SQL written for MySQL on Firebird becuase the
latter doesn't support nested selects in all the places the
former does....

--
\S -- si***@chiark.gr eenend.org.uk -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu becomež se bera eadward ofdun hlęddre heafdes bęce bump bump bump
Jul 18 '05 #11
David Fraser <da****@sjsoft. com> wrote:
What we have found the best approach is to start development with two
databases in mind. In that case, you have to build in a basic layer of
database-independence. Then later, adding other databases tends to be an
easy refactor.


Seconded. I'm currently working on sticking a Firebird backend
onto an application which already supports Oracle and MySQL.
Thanks to the DB API, there's a lot of code which can be shared
in a base class, and for the most part the SQL-dialect-specific
tweaks are easy to stick in methods which override the common
code in a derived class. The biggest difference is in the SQL
needed for creating the tables in the DB in the first place.
I'd hate to be doing this in any language other than Python,
of course....

--
\S -- si***@chiark.gr eenend.org.uk -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu becomež se bera eadward ofdun hlęddre heafdes bęce bump bump bump
Jul 18 '05 #12
"If"??? I think they are still on the TBD list for MySQL, so at
the moment it is not an "if", it is an "as". <G>


Take a look at the column types PostgreSQL offers.
Among other interesting things, like a datetime type which works, it has
arrays.
You can define a column as an array of integers for instance.
Example :

Imagine we create a table to hold the index of a book. We should have
this (in pseudo-sql):

table words:
id integer primary key
word varchar

table refs:
page integer not null
word_id integer not null references words(id)

index on all interesting columns.

To find all pages where a word is, we look in "words" (index lookup on
word) and find the word id ; then we look in "refs" all pages with the
corresponding word_id
To find all words on a page, we look in "refs" (index lookup on page),
then we group by word, and we look in words to list the words.

With an array type, we have :

table words:
id integer primary key
word varchar
page integer[]

Then you can use a GIST index on page and ask it "find all rows where the
page list contains this page". This is a lot faster than the above Joins.
Getting the list of pages for a word is also a lot faster (it's only one
select, maximal locality of reference).
The GIST indexes are so optimized in Postgres that the speed for these
lookups is amazing.

I tested this feature by building a list of 100.000 words which appeared
in anything from 1 to 10 different random pages (between 1 and 1000). When
finding all words on a page, the GIST index had acceptable timings (ie. a
few tens of milliseconds to return between a few hundred and a few
thousands records) ; the pivot table had horrendous timings on the verge
of a second (because the Join was looking in the pivot table for the
condition first, then making index lookups for each row in this large
table, which is the only way to do it... and makes a lot of disk seeks !)

If you want to use a "minimal subset of SQL", you'll have to forgo these
interesting features...

Postgresql has indexable geometric types. On a random population of
500.000 points, it takes 90 ms to get the points in a certain bounding box
(this particular query returned 5.000 points)... without clustering on the
index it took about 200 ms...
So, if you want performance, it is difficult to ignore database-specific
points.

I know MySQL has geometric types too. But only for MyISAM tables !
(argh). So you don't get transactions on them. And MyISAM tables have
terrible write concurrency.

Jul 18 '05 #13
Marco Aschwanden <PP**********@s pammotel.com> wrote:

Hi

I would like to develop an app that is (more or less) database
independet.


No such thing. Entire database industry is about locking in customer to
their own products and upgrades, and to prevent migration to their
competitors at all cost. Even with "open source" database like MySQL
and PostgreSQL, you'll see sufficient differences in C API which will
cause you to abandon what you're trying to do.

This conclusion is result of my attempt to add database interfaces to
shell:
http://freshmeat.net/projects/bashdiff/
http://freshmeat.net/projects/basp/

--
William Park, Open Geometry Consulting, <op**********@y ahoo.ca>
Q: What do you use to remove bugs on your Windows? A: Windex.
Jul 18 '05 #14
Marco Aschwanden wrote:
I am wondering if anyone has a link / hint / book that
assembled this minimum sql.


"SQL in a Nutshell" from O'Reilly documents both SQL99 and the deviations of
Oracle, MS SQLServer, MySQL, and PostgreSQL (including lists of vender
specific keywords). Don't know if it is quite what you're looking for, but
it might help.

That said, I'm not sure that trying for DB independence is really what you
need to do. By doing that you not only make your life more difficult from
an implementation PoV (by not taking advantages of useful utilities and
extensions offered by the specific vendor), but you may not be able to
provide the level of performance demanded by customers (depending on the
size of your application).

I recently developed an application for an Oracle database. (prototyped in
Python, but moved to C#/.NET cuz that's what was wanted). The original
version used pretty standard SQL and performed correctly. Only problem was
that, under more extreme (but not-atypical) customer loads, it crawled. I
needed to tweak the SQL to play to Oracle's quirks as well as using some of
their packages.

A better approach might be to provide an abstraction layer with
vendor-specific plugins. Above the abstraction layer you expose a model
that's important to your app. Below, you map to the DB.

Just my opinion.

Russell.

Jul 18 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1851
by: Sean | last post by:
I have two sites that i use for personal stuff (family, friends, photos). They are PHP sites butim not a programmer. They were setup by a friend who no longer helps with them. There are some things with the Gallery upload and topics that just don't work anymore. I suspect it would be trivial for someone who knows PHP to fix. I am willing to pay $100 a year for someone to keep the sites up and running...minimal time is needed. ...
1
2081
by: Tom | last post by:
I need a very, very minimal LaTeX system on Windows. I only need to have the possibility to get DVI files out of my tex files (with minimal fonts). An I need it without any installer (no settings in registry and no or less enviroment variables). I know this was asked a few time here but I haven't found any suitable information yet. I posted some time ago under "minimal latex for windows"...
3
3183
by: vato | last post by:
I was hoping to get an example of a C++ program I am working on with my son need to calculate the average of a series of game scores where we can drop the lowest score. ie five games get the best 4 out of 5. He is in c++ and thinks I know about this stuff. I study the book to try to keep ahead of him, but he is a sponge I am wax. I would need something with 3 functions if possible getscore find lowest and average.
1
2430
by: Epetruk | last post by:
Hello all, I'm sorry for the long post, but I think it's better if I'm as detailed as I can be so that I don't make a mistake in my choice and so that there's a clear understanding of to what I'm looking for. I'm looking for a content management system to use on a site (http://www.nigeriavillagesquare.com) that I help to moderate. Unfortunately (as I have discovered), there are literally hundreds of CMS's to choose from, so I am...
3
7734
by: Serious_Practitioner | last post by:
Happy New Year! I am looking around for an MS-Access based database that will help me manage the collections of 20-30 small loans. I need to be able to create amortization schedules when the loan is first made, and then I need to be able to apply payments to principal and interest as the payments come in. Don't need multi-user capability or Web access. Just want to install the thing, maybe do some minimal customization to suit my...
11
308
by: Ron Vecchi | last post by:
I've used System.Web.Mail before but have never had the need to send attchemnets through it...until now. A client of mine would like a form on the website to allow a user to type up a message and upload a file. I'm staying away from mailto links. So the file and message will be uploaded to the server when the user clicks send. The new file and message will be processed and emailed from the server to my client. I'm tring to get any...
20
6057
by: ram.rachum | last post by:
Hey, I'm looking for a good Python environment. That is, at least an editor and a debugger, and it should run on Windows. Does anyone have any idea?
3
1580
by: itisthiyagu | last post by:
Hi, Im looking for ListBox which works like Windows-XP's Add/Remove programs listbox. where can i get this kind of listbox ? I want to show a text in ListItem & it should expand with its description when user selects a particular item. Also i want to add a button into to ListItem. it is same like Add/Remove programs ListBox. anybody help me. -Thiyagu
2
1062
by: cowznofsky | last post by:
My needs are relatively simple. I'm putting together a web site prototype that has some very minimal e-commerce type stuff. I've been away from asp.net for a little while. It's not a store, so I'm not looking for that specific functionality. It will include to facility to maintain a product list. I'm looking for a starter kit that will hande users in different roles, and allow them self-service to maintain their contact information...
0
9535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10467
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10201
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5454
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4130
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.