Thread: Thoughts on "Love Your Database"

Thoughts on "Love Your Database"

From
Guyren Howe
Date:
I've long been frustrated with how most web developers I meet have no idea how to use an SQL database properly. I think
I'mgoing to write a book called Love Your Database, aimed at web developers, that explains how to make their apps
betterby leveraging the power of SQL in general, and Postgres in particular. 

I'm thinking of a section on features of SQL most folks don't know about (CTEs are *way* to hell at the top of that
list,but also EXCEPT/INTERSECT and window functions), but much of the book would be about how to do things server side.
Benchmarksshowing how much faster this can be, but mostly techniques — stored procedures/triggers/rules, views. 

I asked a colleague about the advice I often hear stated but seldom justified, that one shouldn't put business rules in
thedatabase. He offered that server-side code can be hard to debug. 

I'm sure many here would love to see such a book published, maybe some talks on the topic given.


What might I cover that I haven't mentioned? What are the usual objections to server-side code and how can they be met?
When*are* they justified and what should the criteria be to put code in Postgres? Any other thoughts? Any other
websitesor books on the topic I might consult? 

TIA

Re: Thoughts on "Love Your Database"

From
"dandl"
Date:
> owner@postgresql.org] On Behalf Of Guyren Howe

> I've long been frustrated with how most web developers I meet have no idea
> how to use an SQL database properly. I think I'm going to write a book called
> Love Your Database, aimed at web developers, that explains how to make their
> apps better by leveraging the power of SQL in general, and Postgres in
> particular.
>
> I'm thinking of a section on features of SQL most folks don't know about
> (CTEs are *way* to hell at the top of that list, but also EXCEPT/INTERSECT
> and window functions), but much of the book would be about how to do things
> server side. Benchmarks showing how much faster this can be, but mostly
> techniques — stored procedures/triggers/rules, views.
>
> I asked a colleague about the advice I often hear stated but seldom
> justified, that one shouldn't put business rules in the database. He offered
> that server-side code can be hard to debug.
>
> I'm sure many here would love to see such a book published, maybe some talks
> on the topic given.
>
> What might I cover that I haven't mentioned? What are the usual objections to
> server-side code and how can they be met? When *are* they justified and what
> should the criteria be to put code in Postgres? Any other thoughts? Any other
> websites or books on the topic I might consult?

I'm a strong believer in putting the business code next to the data, not the wrong side of the object-relational
divide.However, for many the challenge of writing and debugging SQL code is just too high! The SQL language on many
serverscan do everything but it's clunky, lacks modern language features, is hard to debug, often fragile and really
hardto get right. 

The only thing I can give you that might help is a cookbook on how to do it right:
http://thehelsinkideclaration.blogspot.com.au/2009/03/window-on-data-applications.html.

Meanwhile I'm busy replacing SQL with Andl, which can do everything SQL gets right and avoids most of the things it
getswrong. Look out for an implementation on Postgres real soon now. See
http://www.andl.org/2016/04/postgres-meet-andl/. 

Regards
David M Bennett FACS

Andl - A New Database Language - andl.org







Re: Thoughts on "Love Your Database"

From
"Charles Clavadetscher"
Date:
Good morning

> -----Original Message-----
> From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Guyren Howe
> Sent: Mittwoch, 4. Mai 2016 06:11
> To: pgsql-general <pgsql-general@postgresql.org>
> Subject: [GENERAL] Thoughts on "Love Your Database"
>
> I've long been frustrated with how most web developers I meet have no idea how to use an SQL database properly. I
> think I'm going to write a book called Love Your Database, aimed at web developers, that explains how to make their
> apps better by leveraging the power of SQL in general, and Postgres in particular.
>
> I'm thinking of a section on features of SQL most folks don't know about (CTEs are *way* to hell at the top of that
> list, but also EXCEPT/INTERSECT and window functions), but much of the book would be about how to do things server
> side. Benchmarks showing how much faster this can be, but mostly techniques — stored procedures/triggers/rules,
> views.
>
> I asked a colleague about the advice I often hear stated but seldom justified, that one shouldn't put business rules
> in the database. He offered that server-side code can be hard to debug.
>
> I'm sure many here would love to see such a book published, maybe some talks on the topic given.
>
>
> What might I cover that I haven't mentioned? What are the usual objections to server-side code and how can they be
> met? When *are* they justified and what should the criteria be to put code in Postgres? Any other thoughts? Any
> other websites or books on the topic I might consult?

If you have a complex design or if the processes require the modification of various tables within a transaction you
mayprobably prefer to expose functions as the application interface. Advantages of this approach: 

- Hide complexity: You don't need to explain all the details, dependencies and implications to all web developers. Just
makesure that your documentation is up-to-date for those who want to learn about it. 
- Transactions are controlled by the database: You may have doubts if application developers do handle this correctly.
- Minimize the impact on application development: If changes to requirements force changes in the database, these would
betransparent to the application. Even if the interface changes, that may mean only an additional argument to a
function.
- Security: You can grant execute on (security definer) functions instead of granting privileges for each object. The
lattercan become quite complex. 
- Separation of concerns: Application developers don't need to (but can if they want) learn SQL. They should focus
insteadon the presentation layer, which at the end is what customers see and sells. 

Bye
Charles

>
> TIA
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general



Re: Thoughts on "Love Your Database"

From
Chris Travers
Date:
I think one of the key questions is when to put logic in the database (and this is controversial so it may be worth covering from a few angles).  In general my view is:

1.  Data logic belongs in the database
2.  Logic you can't roll back belongs somewhere else
3.  A lot of stuff could go either place.

Another thing I would recommend is looking at SQL in a way that is similar to map(), reduce(), and filter() (using python terms but you can find similar in other languages).

Additionally some functional programming theory can go a long way in both understanding database normalization and putting logic in the database.

On Wed, May 4, 2016 at 6:11 AM, Guyren Howe <guyren@gmail.com> wrote:
I've long been frustrated with how most web developers I meet have no idea how to use an SQL database properly. I think I'm going to write a book called Love Your Database, aimed at web developers, that explains how to make their apps better by leveraging the power of SQL in general, and Postgres in particular.

I'm thinking of a section on features of SQL most folks don't know about (CTEs are *way* to hell at the top of that list, but also EXCEPT/INTERSECT and window functions), but much of the book would be about how to do things server side. Benchmarks showing how much faster this can be, but mostly techniques — stored procedures/triggers/rules, views.

I asked a colleague about the advice I often hear stated but seldom justified, that one shouldn't put business rules in the database. He offered that server-side code can be hard to debug.

I'm sure many here would love to see such a book published, maybe some talks on the topic given.


What might I cover that I haven't mentioned? What are the usual objections to server-side code and how can they be met? When *are* they justified and what should the criteria be to put code in Postgres? Any other thoughts? Any other websites or books on the topic I might consult?

TIA

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



--
Best Wishes,
Chris Travers

Efficito:  Hosted Accounting and ERP.  Robust and Flexible.  No vendor lock-in.

Re: Thoughts on "Love Your Database"

From
Bill Moran
Date:
On Tue, 3 May 2016 23:11:06 -0500
Guyren Howe <guyren@gmail.com> wrote:

> I've long been frustrated with how most web developers I meet have no idea how to use an SQL database properly. I
thinkI'm going to write a book called Love Your Database, aimed at web developers, that explains how to make their apps
betterby leveraging the power of SQL in general, and Postgres in particular. 
>
> I'm thinking of a section on features of SQL most folks don't know about (CTEs are *way* to hell at the top of that
list,but also EXCEPT/INTERSECT and window functions), but much of the book would be about how to do things server side.
Benchmarksshowing how much faster this can be, but mostly techniques ? stored procedures/triggers/rules, views. 
>
> I asked a colleague about the advice I often hear stated but seldom justified, that one shouldn't put business rules
inthe database. He offered that server-side code can be hard to debug. 
>
> I'm sure many here would love to see such a book published, maybe some talks on the topic given.
>
>
> What might I cover that I haven't mentioned? What are the usual objections to server-side code and how can they be
met?When *are* they justified and what should the criteria be to put code in Postgres? Any other thoughts? Any other
websitesor books on the topic I might consult? 

Not a specific topic, but as a general theme, a lot of developers don't
seem to think it's useful for them to know SQL, and therefore don't
bother trying -- or even actively resist learning.

So if the overall theme is "knowing this makes things better", I would
buy multiple copies of the book an mysteriously leave it on various
developer's desks.

--
Bill Moran


Re: Thoughts on "Love Your Database"

From
Geoff Winkless
Date:
On 4 May 2016 at 06:46, dandl <david@andl.org> wrote:
> I'm a strong believer in putting the business code next to the data, not the wrong
> side of the object-relational divide. However, for many the challenge of writing and
> debugging SQL code is just too high!

Your source for this statement please? "For many" sounds rather like
weasel-words to me. In my experience, a wide range of people, from
beginners to experts, find SQL easy to write and debug. I'm afraid
that the problem seems to me to be that your peg is rather too square.

> Meanwhile I'm busy replacing SQL with Andl, which can do everything SQL gets
> right and avoids most of the things it gets wrong. Look out for an implementation
> on Postgres real soon now. See http://www.andl.org/2016/04/postgres-meet-andl/.

Please, can you stop spamming every marginally-related topic in the
list with this? I'm sure that anyone who's interested in this will
have seen it in the thread you created that was actually marked with
it in the subject.

Geoff


Re: Thoughts on "Love Your Database"

From
Chris Travers
Date:
A few observations

On Wed, May 4, 2016 at 12:31 PM, Geoff Winkless <pgsqladmin@geoff.dj> wrote:
On 4 May 2016 at 06:46, dandl <david@andl.org> wrote:
> I'm a strong believer in putting the business code next to the data, not the wrong
> side of the object-relational divide. However, for many the challenge of writing and
> debugging SQL code is just too high!

Your source for this statement please? "For many" sounds rather like
weasel-words to me. In my experience, a wide range of people, from
beginners to experts, find SQL easy to write and debug. I'm afraid
that the problem seems to me to be that your peg is rather too square.


I actually agree with dandl on this.  Folks can write SQL but often aren't really comfortable using it as core application logic.

I.e. one often sees code that retrieves a bunch of records from the db, loops through them, and transforms the data as part of the OLTP workflow.  It is obviously much better of one can think about SQL as business logic but this is not that often.

I.e. people think the peg is square but indeed it is round.
 



--
Best Wishes,
Chris Travers

Efficito:  Hosted Accounting and ERP.  Robust and Flexible.  No vendor lock-in.

Re: Thoughts on "Love Your Database"

From
Szymon Lipiński
Date:


On 4 May 2016 at 13:13, Chris Travers <chris.travers@gmail.com> wrote:
A few observations

On Wed, May 4, 2016 at 12:31 PM, Geoff Winkless <pgsqladmin@geoff.dj> wrote:
On 4 May 2016 at 06:46, dandl <david@andl.org> wrote:
> I'm a strong believer in putting the business code next to the data, not the wrong
> side of the object-relational divide. However, for many the challenge of writing and
> debugging SQL code is just too high!

Your source for this statement please? "For many" sounds rather like
weasel-words to me. In my experience, a wide range of people, from
beginners to experts, find SQL easy to write and debug. I'm afraid
that the problem seems to me to be that your peg is rather too square.


I actually agree with dandl on this.  Folks can write SQL but often aren't really comfortable using it as core application logic.

I.e. one often sees code that retrieves a bunch of records from the db, loops through them, and transforms the data as part of the OLTP workflow.  It is obviously much better of one can think about SQL as business logic but this is not that often.

I.e. people think the peg is square but indeed it is round.
 


From my perspective there is one more thing: when I tried, in couple of companies, to move some part of the logic to a database, then usually the management said "no, that's not doable, as we will have trouble with finding good sql programmers later", and we were still writing all the logic outside the database.

 

--
    regards Szymon Lipiński

Re: Thoughts on "Love Your Database"

From
"dandl"
Date:
> owner@postgresql.org] On Behalf Of Geoff Winkless

> > I'm a strong believer in putting the business code next to the data,
> > not the wrong side of the object-relational divide. However, for many
> > the challenge of writing and debugging SQL code is just too high!
>
> Your source for this statement please? "For many" sounds rather like weasel-
> words to me. In my experience, a wide range of people, from beginners to
> experts, find SQL easy to write and debug. I'm afraid that the problem seems
> to me to be that your peg is rather too square.

Then I think you've seriously misunderstood. Most people can indeed learn to write basic SQL queries, but those are
(obviously)not what I'm talking about. 

To write the business logic of a significant application entirely in SQL requires PLSQL (or in other dialects, whatever
passesfor SQL/PSM). It means writing an entire data access layer as a set of stored procedures, with a substantial set
ofspecial functions, types, triggers and so on. No beginner and few experts have the skills required to do that in SQL,
andthen debug that code on the server. The plain aim of Andl is make this task far, far easier so that indeed a
beginnercan do it. 

> > Meanwhile I'm busy replacing SQL with Andl, which can do everything
> > SQL gets right and avoids most of the things it gets wrong. Look out
> > for an implementation on Postgres real soon now. See
> http://www.andl.org/2016/04/postgres-meet-andl/.
>
> Please, can you stop spamming every marginally-related topic in the list with
> this? I'm sure that anyone who's interested in this will have seen it in the
> thread you created that was actually marked with it in the subject.

The man asked a question and I gave him two links that provide specific parts of my answer. I think you would learn
somethingfrom reading them, but perhaps the simplest solution is that you just ignore my posts in future. 

Regards
David M Bennett FACS

Andl - A New Database Language - andl.org







Re: Thoughts on "Love Your Database"

From
Szymon Lipiński
Date:


On 4 May 2016 at 06:11, Guyren Howe <guyren@gmail.com> wrote:
I've long been frustrated with how most web developers I meet have no idea how to use an SQL database properly. I think I'm going to write a book called Love Your Database, aimed at web developers, that explains how to make their apps better by leveraging the power of SQL in general, and Postgres in particular.

I'm thinking of a section on features of SQL most folks don't know about (CTEs are *way* to hell at the top of that list, but also EXCEPT/INTERSECT and window functions), but much of the book would be about how to do things server side. Benchmarks showing how much faster this can be, but mostly techniques — stored procedures/triggers/rules, views.

I asked a colleague about the advice I often hear stated but seldom justified, that one shouldn't put business rules in the database. He offered that server-side code can be hard to debug.

I'm sure many here would love to see such a book published, maybe some talks on the topic given.


What might I cover that I haven't mentioned? What are the usual objections to server-side code and how can they be met? When *are* they justified and what should the criteria be to put code in Postgres? Any other thoughts? Any other websites or books on the topic I might consult?

TIA

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Hi,
at my previous jobs I was working with many programmers, and almost none of them understood SQL. The problem was even deeper. They didn't want to learn it. When I was working among java programmers, I noticed that they hated SQL, but there was no problem with learning HQL, which in fact is quite similar. I really have no idea why it is like that.

I was thinking about such a book too, I have even started writing that, but the whole set of ideas was always either too large or was a copy of what can be found in other, general programming books. And if programmers don't want to read the other books, and learn basics of SQL from there, then the whole idea seemed useless to me. Of course the other reason of not writing the book was lack of time, as writing a good book requires enormous amount of work.

On the other hand I think that the huge problem with programmers and SQL is changing the mindset. A standard programmer usually has a problem with thinking in sets. Instead she usually thinks in terms of loops, and objects.

When I was giving talks about what not to do in databases, people were either not interested or everything was a surprise for them, even for quite experienced programmers. However after such a talk, or a training, people were still not interested in knowing more, but they were happily learning about programming.

I think it would be great to have a book like that, and I think it should not be only about Postgres. But here is the problem I had with this concept: to describe all the things to a normal programmer, assuming she will be interested, it will need to be quite a huge and complicated book.

Or maybe this book should be about something else, start from an ORM, and show how to translate it to much better SQL, as ORMs are the things programmers usually understand, and they really don't bother that using them can be a bad idea.


--
    regards Szymon Lipiński

Re: Thoughts on "Love Your Database"

From
John McKown
Date:
On Wed, May 4, 2016 at 7:55 AM, Szymon Lipiński <mabewlun@gmail.com> wrote:
​<snip>​
 
Hi,
at my previous jobs I was working with many programmers, and almost none of them understood SQL. The problem was even deeper. They didn't want to learn it. When I was working among java programmers, I noticed that they hated SQL, but there was no problem with learning HQL, which in fact is quite similar. I really have no idea why it is like that.

I was thinking about such a book too, I have even started writing that, but the whole set of ideas was always either too large or was a copy of what can be found in other, general programming books. And if programmers don't want to read the other books, and learn basics of SQL from there, then the whole idea seemed useless to me. Of course the other reason of not writing the book was lack of time, as writing a good book requires enormous amount of work.

On the other hand I think that the huge problem with programmers and SQL is changing the mindset. A standard programmer usually has a problem with thinking in sets. Instead she usually thinks in terms of loops, and objects.

​Very true. What _really_ was of help to me was the fact that I had learned APL in college. APL is an vector / array oriented language with operators which work on entire data structures, rather than individual array elements. E.g. to sum all the number in a vector is simply "+/vector".
 

When I was giving talks about what not to do in databases, people were either not interested or everything was a surprise for them, even for quite experienced programmers. However after such a talk, or a training, people were still not interested in knowing more, but they were happily learning about programming.

I think it would be great to have a book like that, and I think it should not be only about Postgres. But here is the problem I had with this concept: to describe all the things to a normal programmer, assuming she will be interested, it will need to be quite a huge and complicated book.

Or maybe this book should be about something else, start from an ORM, and show how to translate it to much better SQL, as ORMs are the things programmers usually understand, and they really don't bother that using them can be a bad idea.


--
    regards Szymon Lipiński

​What I have heard of are shops in which the application programmers simply DO NOT CODE any SQL. They only use stored procedures which they view as subroutine calls. The stored procedures are written by the DBAs and other SQL experts. That group has hard control over the enterprise data. If the programmers need something, they become like end-user in that they simply describe what data they need and why. The programmers basically know enough to be able to ask for something. Completely unlike back in the days of indexed (DBM basically) files​.


--
The unfacts, did we have them, are too imprecisely few to warrant our certitude.

Maranatha! <><
John McKown

Re: Thoughts on "Love Your Database"

From
Sándor Daku
Date:
On 4 May 2016 at 13:36, Szymon Lipiński <mabewlun@gmail.com> wrote:


On 4 May 2016 at 13:13, Chris Travers <chris.travers@gmail.com> wrote:
A few observations

On Wed, May 4, 2016 at 12:31 PM, Geoff Winkless <pgsqladmin@geoff.dj> wrote:
On 4 May 2016 at 06:46, dandl <david@andl.org> wrote:
> I'm a strong believer in putting the business code next to the data, not the wrong
> side of the object-relational divide. However, for many the challenge of writing and
> debugging SQL code is just too high!

Your source for this statement please? "For many" sounds rather like
weasel-words to me. In my experience, a wide range of people, from
beginners to experts, find SQL easy to write and debug. I'm afraid
that the problem seems to me to be that your peg is rather too square.


I actually agree with dandl on this.  Folks can write SQL but often aren't really comfortable using it as core application logic.

I.e. one often sees code that retrieves a bunch of records from the db, loops through them, and transforms the data as part of the OLTP workflow.  It is obviously much better of one can think about SQL as business logic but this is not that often.

I.e. people think the peg is square but indeed it is round.
 


From my perspective there is one more thing: when I tried, in couple of companies, to move some part of the logic to a database, then usually the management said "no, that's not doable, as we will have trouble with finding good sql programmers later", and we were still writing all the logic outside the database.


Yeah. The classic "We have a bunch of scissors, so use them instead of screwdrivers. Oh, and by the way, please redesign our screws, to make them more scissor compatible." approach. :)
The real shame, when they buy an expensive, feature-rich DBMS, run it on a kick ass hardware and then using it as a glorified file cabinet.

Regards,
Sándor

Re: Thoughts on "Love Your Database"

From
Geoff Winkless
Date:
On 4 May 2016 at 12:36, Szymon Lipiński <mabewlun@gmail.com> wrote:
> From my perspective there is one more thing: when I tried, in couple of
> companies, to move some part of the logic to a database, then usually the
> management said "no, that's not doable, as we will have trouble with finding
> good sql programmers later", and we were still writing all the logic outside
> the database.

"Finding good programmers later" will always be hard. There are less
of them about than Human Resources would like to believe.

Putting your logic in a different layer or in a different language
over the top of SQL doesn't mean you won't need good programmers
later; quite the reverse, because now you need programmers who are
both strong in SQL _and_ good enough to understand the layer you've
added on top.

On the other hand, if you're planning on putting _some_ of your logic
into the database, then I probably see where they're coming from. If
you give full database access to application developers (rather than
providing them with stored procedures that perform the tasks for them)
then they will be surprised as hell when the database does something
they weren't expecting because of some business rules that are in a
fourth-level trigger somewhere.

The sensible way is to do it as John wrote - to restrict access rights
to everyone except admin to calling functions only. That way the
functions are written by the people who are paid to understand the
business rules and the data behind it, and the application developers
can ask those experts to do the heavy lifting for them. Having to
persuade management that they should no longer be able to connect the
database to MS Access and make changes that way will usually put an
end to that pure model, though. :)

Geoff


Re: Thoughts on "Love Your Database"

From
John McKown
Date:
On Wed, May 4, 2016 at 8:13 AM, Geoff Winkless <pgsqladmin@geoff.dj> wrote:
​<snip>

The sensible way is to do it as John wrote - to restrict access rights
to everyone except admin to calling functions only. That way the
functions are written by the people who are paid to understand the
business rules and the data behind it, and the application developers
can ask those experts to do the heavy lifting for them. Having to
persuade management that they should no longer be able to connect the
database to MS Access and make changes that way will usually put an
end to that pure model, though. :)

​Allowing PHBs direct access t​o company data is a nasty thing. They become like some users who "know Excel". They are now just as knowledgeable as someone who's been doing this for years. I've actually heard one say something akin to: "Damn it, I can write Excel formulas. I know very well that an new function on the web site could be written in less than a day, if you'd just get off you a$$ and do it."

 

Geoff





--
The unfacts, did we have them, are too imprecisely few to warrant our certitude.

Maranatha! <><
John McKown

Re: Thoughts on "Love Your Database"

From
Melvin Davidson
Date:


On Wed, May 4, 2016 at 9:25 AM, John McKown <john.archie.mckown@gmail.com> wrote:
On Wed, May 4, 2016 at 8:13 AM, Geoff Winkless <pgsqladmin@geoff.dj> wrote:
​<snip>

The sensible way is to do it as John wrote - to restrict access rights
to everyone except admin to calling functions only. That way the
functions are written by the people who are paid to understand the
business rules and the data behind it, and the application developers
can ask those experts to do the heavy lifting for them. Having to
persuade management that they should no longer be able to connect the
database to MS Access and make changes that way will usually put an
end to that pure model, though. :)

​Allowing PHBs direct access t​o company data is a nasty thing. They become like some users who "know Excel". They are now just as knowledgeable as someone who's been doing this for years. I've actually heard one say something akin to: "Damn it, I can write Excel formulas. I know very well that an new function on the web site could be written in less than a day, if you'd just get off you a$$ and do it."

 

Geoff





--
The unfacts, did we have them, are too imprecisely few to warrant our certitude.

Maranatha! <><
John McKown

>What might I cover that I haven't mentioned?

Well, I'm pretty sure that one of the reasons Web Developers do not use SQL is because they do not know what is in the database. Perhaps a sections that teaches them how to list the tables and columns
from the INFORMATION_SCHEMA would be a good start.


--
Melvin Davidson
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.

Re: Thoughts on "Love Your Database"

From
Pierre Chevalier Géologue
Date:
Hi,

Le 04/05/2016 13:36, Szymon Lipiński a écrit :
> On 4 May 2016 at 13:13, Chris Travers <chris.travers@gmail.com
> <mailto:chris.travers@gmail.com>> wrote:
>     A few observations
>
>     On Wed, May 4, 2016 at 12:31 PM, Geoff Winkless <pgsqladmin@geoff.dj
>     <mailto:pgsqladmin@geoff.dj>> wrote:
>
>         On 4 May 2016 at 06:46, dandl <david@andl.org
>         <mailto:david@andl.org>> wrote:
>         > I'm a strong believer in putting the business code next to the data, not the wrong
>         > side of the object-relational divide. However, for many the challenge of writing and
>         > debugging SQL code is just too high!
>
>         Your source for this statement please? "For many" sounds rather like
>         weasel-words to me. In my experience, a wide range of people, from
>         beginners to experts, find SQL easy to write and debug.

Yes, I agree. SQL is just crystal-clear to write, read and understand. I
found out that debugging is usually not a common exercise in SQL,
because the language is so trivial.


...
>  From my perspective there is one more thing: when I tried, in couple of
> companies, to move some part of the logic to a database, then usually
> the management said "no, that's not doable, as we will have trouble with
> finding good sql programmers later",

Shocking! Apart from very few languages I know, SQL is by far more
productive and efficient, for many-many tasks.


> and we were still writing all the logic outside the database.

I used to implement the logic outside the database, like you mention,
*but* I was writing plain SQL.  Only when I had specific needs, then I
would switch to another language which would just get the results from a
well-polished plain SQL query, process, and feed back things into the
database (with another well-polished SQL, of course) or just throw the
results out somewhere else (file, screen, picture, whatever).  No ORM or
any complication.

And I find SQL fairly easy to debug and maintain, no need for fancy
tools: an editor and a console (psql or equivalent) and you're up and going!


Nowadays, things got quite different, and I tend to stuff more and more
logic inside the database. Which is often merely converting SQL queries
into views...

But it comes with a counterpart: the more you put logic inside your
DBMS, the more dependent you become. As far as I'm concerned, I recently
decided to just stick to PostgreSQL forever! (or almost)

À+
Pierre

PS: sorry for the double-reply, Szymon: I forgot *again* to hit
Shift-Ctrl-R instead of Ctrl-R, shame on me...
--
____________________________________________________________________________
Pierre Chevalier
PChGEI: Pierre Chevalier Géologue Et Informaticien
Partenaire DALIBO
     Mesté Duran
     32100 Condom
   Tél+fax  :    09 75 27 45 62
                 06 37 80 33 64
   Émail  :   pierrechevaliergeolCHEZfree.fr
   icq#   :   10432285
   jabber: pierre.chevalier1967@jabber.fr
   http://pierremariechevalier.free.fr/pierre_chevalier_geologue
____________________________________________________________________________


Re: Thoughts on "Love Your Database"

From
Pierre Chevalier Géologue
Date:
Le 04/05/2016 15:25, John McKown a écrit :
> On Wed, May 4, 2016 at 8:13 AM, Geoff Winkless <pgsqladmin@geoff.dj
> <mailto:pgsqladmin@geoff.dj>>wrote:
>
>     ​<snip>
>
>     The sensible way is to do it as John wrote - to restrict access rights
>     to everyone except admin to calling functions only. That way the
>     functions are written by the people who are paid to understand the
>     business rules and the data behind it, and the application developers
>     can ask those experts to do the heavy lifting for them. Having to
>     persuade management that they should no longer be able to connect the
>     database to MS Access and make changes that way will usually put an
>     end to that pure model, though. :)
>
>
> ​Allowing PHBs direct access t​o company data is a nasty thing.

Sorry, what is a PHB?  Our friend google didn't help me much on this matter.


> They become like some users who "know Excel". They are now just as
> knowledgeable as someone who's been doing this for years. I've actually
> heard one say something akin to: "Damn it, I can write Excel formulas. I
> know very well that an new function on the web site could be written in
> less than a day, if you'd just get off you a$$ and do it."

Hm.  Sounds familiar...
I usually call "excelitis" a sort of mental disease related to a use and
abuse of Excel, up to the point where one cannot imagine data which is
*not* in a table-like array.  And they think that they do Relational
Database Management...  In the 1990's, I met many-many deeply sick
persons.  I had been infected for a while, I must confess.

À+
Pierre
--
____________________________________________________________________________
Pierre Chevalier
PChGEI: Pierre Chevalier Géologue Et Informaticien
Partenaire DALIBO
     Mesté Duran
     32100 Condom
   Tél+fax  :    09 75 27 45 62
                 06 37 80 33 64
   Émail  :   pierrechevaliergeolCHEZfree.fr
   icq#   :   10432285
   jabber: pierre.chevalier1967@jabber.fr
   http://pierremariechevalier.free.fr/pierre_chevalier_geologue
____________________________________________________________________________


Re: Thoughts on "Love Your Database"

From
Pierre Chevalier Géologue
Date:
Le 04/05/2016 13:36, dandl a écrit :
...
> Then I think you've seriously misunderstood. Most people can
>indeed learn to write basic SQL queries, but those are
>(obviously) not what I'm talking about.
>
> To write the business logic of a significant application
>entirely in SQL requires PLSQL (or in other dialects, whatever
>passes for SQL/PSM). It means writing an entire data access
>layer as a set of stored procedures, with a substantial set of
>special functions, types, triggers and so on. No beginner and
>few experts have the skills required to do that in SQL, and then
>debug that code on the server.

All right, I understand better now.  I think I also totally missed your
point, sorry...
I'll give a look at andl.

À+
Pierre
--
____________________________________________________________________________
Pierre Chevalier
PChGEI: Pierre Chevalier Géologue Et Informaticien
Partenaire DALIBO
     Mesté Duran
     32100 Condom
   Tél+fax  :    09 75 27 45 62
                 06 37 80 33 64
   Émail  :   pierrechevaliergeolCHEZfree.fr
   icq#   :   10432285
   jabber: pierre.chevalier1967@jabber.fr
   http://pierremariechevalier.free.fr/pierre_chevalier_geologue
____________________________________________________________________________


Re: Thoughts on "Love Your Database"

From
Steve Crawford
Date:
First, you hit them over the head with a copy of "SQL Antipatterns: Avoiding the Pitfalls of Database Programming". It is a tad out of date and tends to use PHP and MySQL for the main examples but does also address different solutions available in PostgreSQL, Oracle. MS SQL server, etc. while pointing out the risks of various common foot-guns and providing alternatives.

Or point them to this recent Linux Journal article by Reuven Lerner (who is occasionally seen on these lists):

Developers often have a pre-Gallileo world view that they and whatever app they are coding is the center of the universe and databases, networks, storage and the rest all revolve around them existing only to support their app.

But ultimately the church of the developer gets forced into the modern era and finds that the data is at the center and the apps that allow input, maintenance, extraction and analysis all revolve around those core crown jewels. Then, *gasp*, there are other people and apps touching "your" data. Are they all validating the data the way you do? Protecting it? Retrieving it efficiently? Only then does the real value of the database come into focus.

Cheers,
Steve





On Tue, May 3, 2016 at 9:11 PM, Guyren Howe <guyren@gmail.com> wrote:
I've long been frustrated with how most web developers I meet have no idea how to use an SQL database properly. I think I'm going to write a book called Love Your Database, aimed at web developers, that explains how to make their apps better by leveraging the power of SQL in general, and Postgres in particular.

I'm thinking of a section on features of SQL most folks don't know about (CTEs are *way* to hell at the top of that list, but also EXCEPT/INTERSECT and window functions), but much of the book would be about how to do things server side. Benchmarks showing how much faster this can be, but mostly techniques — stored procedures/triggers/rules, views.

I asked a colleague about the advice I often hear stated but seldom justified, that one shouldn't put business rules in the database. He offered that server-side code can be hard to debug.

I'm sure many here would love to see such a book published, maybe some talks on the topic given.


What might I cover that I haven't mentioned? What are the usual objections to server-side code and how can they be met? When *are* they justified and what should the criteria be to put code in Postgres? Any other thoughts? Any other websites or books on the topic I might consult?

TIA

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: Thoughts on "Love Your Database"

From
Will McCormick
Date:
A reason to consider may be portability. What happens if I want to let my customer chose their data store or I just don't want to put all my eggs in one basket.Technically there are truths but you cannot ignore the business side either. If a we can exceed our performance requirements and keep things generic/portable this is the best of both worlds.I think this is the main reason people separate the business logic from the database. How many of you have ported databases between platforms? Or had multiple types of data stores in the same company?

On Wed, May 4, 2016 at 12:11 AM, Guyren Howe <guyren@gmail.com> wrote:
I've long been frustrated with how most web developers I meet have no idea how to use an SQL database properly. I think I'm going to write a book called Love Your Database, aimed at web developers, that explains how to make their apps better by leveraging the power of SQL in general, and Postgres in particular.

I'm thinking of a section on features of SQL most folks don't know about (CTEs are *way* to hell at the top of that list, but also EXCEPT/INTERSECT and window functions), but much of the book would be about how to do things server side. Benchmarks showing how much faster this can be, but mostly techniques — stored procedures/triggers/rules, views.

I asked a colleague about the advice I often hear stated but seldom justified, that one shouldn't put business rules in the database. He offered that server-side code can be hard to debug.

I'm sure many here would love to see such a book published, maybe some talks on the topic given.


What might I cover that I haven't mentioned? What are the usual objections to server-side code and how can they be met? When *are* they justified and what should the criteria be to put code in Postgres? Any other thoughts? Any other websites or books on the topic I might consult?

TIA

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: Thoughts on "Love Your Database"

From
Steve Crawford
Date:
Perhaps a bit US centric but PHB = Pointy Haired Boss. See the boss in "Dilbert".

Cheers,
Steve

On Wed, May 4, 2016 at 7:55 AM, Pierre Chevalier Géologue <pierrechevaliergeol@free.fr> wrote:
Le 04/05/2016 15:25, John McKown a écrit :
On Wed, May 4, 2016 at 8:13 AM, Geoff Winkless <pgsqladmin@geoff.dj
<mailto:pgsqladmin@geoff.dj>>wrote:

    ​<snip>

    The sensible way is to do it as John wrote - to restrict access rights
    to everyone except admin to calling functions only. That way the
    functions are written by the people who are paid to understand the
    business rules and the data behind it, and the application developers
    can ask those experts to do the heavy lifting for them. Having to
    persuade management that they should no longer be able to connect the
    database to MS Access and make changes that way will usually put an
    end to that pure model, though. :)


​Allowing PHBs direct access t​o company data is a nasty thing.

Sorry, what is a PHB?  Our friend google didn't help me much on this matter.


They become like some users who "know Excel". They are now just as
knowledgeable as someone who's been doing this for years. I've actually
heard one say something akin to: "Damn it, I can write Excel formulas. I
know very well that an new function on the web site could be written in
less than a day, if you'd just get off you a$$ and do it."

Hm.  Sounds familiar...
I usually call "excelitis" a sort of mental disease related to a use and abuse of Excel, up to the point where one cannot imagine data which is *not* in a table-like array.  And they think that they do Relational Database Management...  In the 1990's, I met many-many deeply sick persons.  I had been infected for a while, I must confess.

À+
Pierre

--
____________________________________________________________________________
Pierre Chevalier
PChGEI: Pierre Chevalier Géologue Et Informaticien
Partenaire DALIBO
    Mesté Duran
    32100 Condom
  Tél+fax  :    09 75 27 45 62
                06 37 80 33 64
  Émail  :   pierrechevaliergeolCHEZfree.fr
  icq#   :   10432285
  jabber: pierre.chevalier1967@jabber.fr
  http://pierremariechevalier.free.fr/pierre_chevalier_geologue
____________________________________________________________________________


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: Thoughts on "Love Your Database"

From
Steve Crawford
Date:


On Wed, May 4, 2016 at 8:04 AM, Steve Crawford <scrawford@pinpointresearch.com> wrote:
First, you hit them over the head with a copy of "SQL Antipatterns: Avoiding the Pitfalls of Database Programming". It is a tad out of date and tends to use PHP and MySQL for the main examples but does also address different solutions available in PostgreSQL, Oracle. MS SQL server, etc. while pointing out the risks of various common foot-guns and providing alternatives.

Or point them to this recent Linux Journal article by Reuven Lerner (who is occasionally seen on these lists):

Developers often have a pre-Gallileo world view that they and whatever app they are coding is the center of the universe and databases, networks, storage and the rest all revolve around them existing only to support their app.

But ultimately the church of the developer gets forced into the modern era and finds that the data is at the center and the apps that allow input, maintenance, extraction and analysis all revolve around those core crown jewels. Then, *gasp*, there are other people and apps touching "your" data. Are they all validating the data the way you do? Protecting it? Retrieving it efficiently? Only then does the real value of the database come into focus.

Cheers,
Steve





On Tue, May 3, 2016 at 9:11 PM, Guyren Howe <guyren@gmail.com> wrote:
I've long been frustrated with how most web developers I meet have no idea how to use an SQL database properly. I think I'm going to write a book called Love Your Database, aimed at web developers, that explains how to make their apps better by leveraging the power of SQL in general, and Postgres in particular.

I'm thinking of a section on features of SQL most folks don't know about (CTEs are *way* to hell at the top of that list, but also EXCEPT/INTERSECT and window functions), but much of the book would be about how to do things server side. Benchmarks showing how much faster this can be, but mostly techniques — stored procedures/triggers/rules, views.

I asked a colleague about the advice I often hear stated but seldom justified, that one shouldn't put business rules in the database. He offered that server-side code can be hard to debug.

I'm sure many here would love to see such a book published, maybe some talks on the topic given.


What might I cover that I haven't mentioned? What are the usual objections to server-side code and how can they be met? When *are* they justified and what should the criteria be to put code in Postgres? Any other thoughts? Any other websites or books on the topic I might consult?

TIA

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


(Apologies for the top-posts - forgot to override the GMail defaults...)

-Steve

Re: Thoughts on "Love Your Database"

From
John McKown
Date:
On Wed, May 4, 2016 at 9:55 AM, Pierre Chevalier Géologue <pierrechevaliergeol@free.fr> wrote:
Le 04/05/2016 15:25, John McKown a écrit :
On Wed, May 4, 2016 at 8:13 AM, Geoff Winkless <pgsqladmin@geoff.dj
<mailto:pgsqladmin@geoff.dj>>wrote:

    ​<snip>

    The sensible way is to do it as John wrote - to restrict access rights
    to everyone except admin to calling functions only. That way the
    functions are written by the people who are paid to understand the
    business rules and the data behind it, and the application developers
    can ask those experts to do the heavy lifting for them. Having to
    persuade management that they should no longer be able to connect the
    database to MS Access and make changes that way will usually put an
    end to that pure model, though. :)


​Allowing PHBs direct access t​o company data is a nasty thing.

Sorry, what is a PHB?  Our friend google didn't help me much on this matter.

​Ah. Sorry. PHB is a "Pointy Haired Boss" and is a reference to the comic "Dilbert". Dilbert is a engineer who works for a boss who is a complete idiot & has his hair moussed up at the sides (I guess it is moussed).

 


They become like some users who "know Excel". They are now just as
knowledgeable as someone who's been doing this for years. I've actually
heard one say something akin to: "Damn it, I can write Excel formulas. I
know very well that an new function on the web site could be written in
less than a day, if you'd just get off you a$$ and do it."

Hm.  Sounds familiar...
I usually call "excelitis" a sort of mental disease related to a use and abuse of Excel, up to the point where one cannot imagine data which is *not* in a table-like array.  And they think that they do Relational Database Management...  In the 1990's, I met many-many deeply sick persons.  I had been infected for a while, I must confess.

​Yes, I keep reading in another forum about how to interface the R language so that the users can continue to input data into Excel, but then have it run a R language script to produce some output. So many there are trying to use Excel as their "user interface" because it is just about all the user knows. I had a manager, long ago, who used a Lotus 1-2-3​ spreadsheet to contain all his memos. I was glassy eyed in disbelief. He also would use his hand calculator to add up the numbers in the spreadsheet to be sure that the summation function in the spreadsheet didn't make a mistake. <shudder/>
 

À+
Pierre


--
The unfacts, did we have them, are too imprecisely few to warrant our certitude.

Maranatha! <><
John McKown

Re: Thoughts on "Love Your Database"

From
Paul Jungwirth
Date:
On 05/03/2016 09:11 PM, Guyren Howe wrote:
> I think I'm going to write a book called Love Your Database, aimed at web developers
>
> What might I cover that I haven't mentioned? What are the usual objections to server-side code and how can they be
met?When *are* they justified and what should the criteria be to put code in Postgres? Any other thoughts? Any other
websitesor books on the topic I might consult? 

I gave a talk here about doing "interesting" Postgres things in Rails:

https://github.com/pjungwir/rails-and-sql-talk

I don't think that will satisfy many people on this list advocating for
stored procedures, but it is an example of trying to teach what SQL can
do, and how you can do those things without losing your convenient and
familiar ORM tools, e.g. running a query and getting back a bunch of
Ruby objects.

I was not really happy with the talk to be honest. I felt it lacked
unity, it didn't fit in the time I had, and it was too split between
"for beginners" and advanced stuff. It was just snippets---in other
words CTEs and window functions :-). I would like to see something that
offers more strategic advice. Give me a plan.

I would be very interested in that book. I think the biggest challenge
will be identifying with your audience: knowing their priorities and
concerns and workflows. My take on the last 25 years of software
architecture theory is "how to put a layer in front of my database." I
think most people who want business logic in the database are dismissive
of this work and too derogatory toward typical web developers, so I
would be pleased to see a book that takes that history more seriously.
You aren't going to convince the world to trade Rails for PLSQL. But are
there ways I can use SQL (and PLSQL) without giving up Rails? How will I
maintain that stuff? Does it play nice with Rails database migrations?
How will I write tests for it? How do I debug it? What principles will
help me draw the line between (PL)SQL and Ruby?

Good luck! I think a book like that would be great.

Paul







Re: Thoughts on "Love Your Database"

From
Alban Hertroys
Date:
On 4 May 2016 at 17:08, John McKown <john.archie.mckown@gmail.com> wrote:
> I had a manager, long ago, who used a Lotus 1-2-3 spreadsheet to
> contain all his memos. I was glassy eyed in disbelief. He also would use his
> hand calculator to add up the numbers in the spreadsheet to be sure that the
> summation function in the spreadsheet didn't make a mistake. <shudder/>

That still happens - we have a few live examples around in this
company. Unfortunately they're not caged and there's no sign "Do not
feed the managers". Admittedly, they're using Excel instead of
Lotus-1-2-3, but that's the only difference.

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.


Re: Thoughts on "Love Your Database"

From
Will McCormick
Date:
I agree it's typically political but so are most things business. Examples:  Companies buy other companies - You are using a competitors data store and want to replace it.  Company needs to compete with competitors and wants to reduce cost ... these are not technical requirements and it's certainly not vapor ideology. I have only worked for startups and have seen this happen at every company i have worked for, yes it is political but yes it happens. Smaller companies are more susceptible to it. 

The reality is somewhere in the middle as it often is. My point is you don't have to replace a million lines of code if you plan upfront. If you don't .. you do.


On Wed, May 4, 2016 at 11:29 AM, Uwe Schroeder <uwe@oss4u.com> wrote:

On Wed, May 04, 2016 11:05:25 AM Will McCormick wrote:

A reason to consider may be portability. What happens if I want to let my customer chose their data store or I just don't want to put all my eggs in one basket.Technically there are truths but you cannot ignore the business side either. If a we can exceed our performance requirements and keep things generic/portable this is the best of both worlds.I think this is the main reason people separate the business logic from the database. How many of you have ported databases between platforms? Or had multiple types of data stores in the same company?

I have been waiting for the portability argument for the last 20+ posts :-) Everyone who did any type of consulting/working in this field knows that latest the second argument from management is “portability”. I have yet to see anyone who really needed to move to a different database. If they did it usually is a political issue and not a technical one (uhh, we hired this new operations manager and MS SQL is so much better than postgresql …) Unless you develop a generic software to be sold to many clients, the choice of data storage is rarely a real concern unless someone who feels the urge to be important starts throwing words he read in a magazine at management. None of my clients ever questioned the database. They either had one which they wanted to use (i.e. they had a big iron IBM with DB2 on it plus a DBA who knew what he was doing) or they didn't care as long as it worked as expected and came with a maintenance contract of sorts.

If you're developing a web application, the least concern is portability (you're not going to replace the million lines of PHP either). The biggest concern should lie with data integrity and API's that protect your data and business logic so you can hire that cheap app development company from overseas your boss recommended (based on a spam email) without running the risk of compromising everything.

Uwe


Re: Thoughts on "Love Your Database"

From
Geoff Winkless
Date:
On 4 May 2016 at 17:14, Will McCormick <wmccormick@gmail.com> wrote:
> Examples:  Companies buy other companies - You are using a competitors data store and want to replace it.  Company
needsto compete with competitors and wants to reduce cost ... 

Or, let's say, massive multibillion-dollar DBMS competitor buys
smaller but very popular DBMS and steadily increases license costs to
try to price out that database and force its customers to its own,
extortionately expensive, database.

Completely hypothetically, of course.

> The reality is somewhere in the middle as it often is. My point is you don't have to replace a million lines of code
ifyou plan upfront. If you don't .. you do. 

Chances are you do anyway. Since no engine is perfect, at some point
you will (assuming it's a non-trivial store) have had to have made
modifications to the data structures or the queries you run to
optimise to a particular DBMS.

But you're right, if you've started out well, it will at least
minimise the amount of change.

Geoff


Re: Thoughts on "Love Your Database"

From
Szymon Lipiński
Date:


On 4 May 2016 at 18:14, Will McCormick <wmccormick@gmail.com> wrote:
I agree it's typically political but so are most things business. Examples:  Companies buy other companies - You are using a competitors data store and want to replace it.  Company needs to compete with competitors and wants to reduce cost ... these are not technical requirements and it's certainly not vapor ideology. I have only worked for startups and have seen this happen at every company i have worked for, yes it is political but yes it happens. Smaller companies are more susceptible to it. 

The reality is somewhere in the middle as it often is. My point is you don't have to replace a million lines of code if you plan upfront. If you don't .. you do.


On Wed, May 4, 2016 at 11:29 AM, Uwe Schroeder <uwe@oss4u.com> wrote:

On Wed, May 04, 2016 11:05:25 AM Will McCormick wrote:

A reason to consider may be portability. What happens if I want to let my customer chose their data store or I just don't want to put all my eggs in one basket.Technically there are truths but you cannot ignore the business side either. If a we can exceed our performance requirements and keep things generic/portable this is the best of both worlds.I think this is the main reason people separate the business logic from the database. How many of you have ported databases between platforms? Or had multiple types of data stores in the same company?

I have been waiting for the portability argument for the last 20+ posts :-) Everyone who did any type of consulting/working in this field knows that latest the second argument from management is “portability”. I have yet to see anyone who really needed to move to a different database. If they did it usually is a political issue and not a technical one (uhh, we hired this new operations manager and MS SQL is so much better than postgresql …) Unless you develop a generic software to be sold to many clients, the choice of data storage is rarely a real concern unless someone who feels the urge to be important starts throwing words he read in a magazine at management. None of my clients ever questioned the database. They either had one which they wanted to use (i.e. they had a big iron IBM with DB2 on it plus a DBA who knew what he was doing) or they didn't care as long as it worked as expected and came with a maintenance contract of sorts.

If you're developing a web application, the least concern is portability (you're not going to replace the million lines of PHP either). The biggest concern should lie with data integrity and API's that protect your data and business logic so you can hire that cheap app development company from overseas your boss recommended (based on a spam email) without running the risk of compromising everything.

Uwe



I'm not sure that when a company buys another company they can just migrate the other database without any logic layer. The data is usually useless without the business layer which tells how to merge all the parts together to have a simple answer to a question like "do we have this in stock". And for such a migration that's not too important if we have the logic in database, or in some other layer. Of course it is always simpler to migrate a database treated like a CSV file, where all the logic (including constraints) is in an external application. But do we really want that?

On the other hand, when I was trying to store all my logic in a database, there was just one thing that made me hate it. Testing. Testing the procedures inside the database was not easy, not funny, and too much time consuming. 

--
    regards Szymon Lipiński

Re: Thoughts on "Love Your Database"

From
Paul Jungwirth
Date:
On 05/04/2016 08:39 AM, Paul Jungwirth wrote:
> On 05/03/2016 09:11 PM, Guyren Howe wrote:
>> I think I'm going to write a book called Love Your Database, aimed at
>> web developers
>
> I gave a talk here about doing "interesting" Postgres things in Rails:

Oh also: one part of my talk I did like what giving my mental process
for building up a query. Because of SQL's declarative nature, a lot of
people just don't know where to start. My own thinking goes like this:

1. Each output row is a _____.
2. Use that for the `FROM`.

 From there, it is easy to JOIN to whatever else I need, add filters,
and fill in the SELECT.

That's worked really well for me. I'd love to hear what other people do,
if you've done any reflection on your own thought process.

I think teaching this is a different thing than just teaching SQL
syntax. I haven't seen it written about a lot. It must be somewhere, but
any book encouraging "outsiders" to use more SQL could benefit from
giving them direction like that.

Paul




Re: Thoughts on "Love Your Database"

From
Will McCormick
Date:
I agree that it's not like turning on the light switch. And I'm not implying there isn't a logic layer between the database and the application. Based off my past experiences I would likely not put business logic in the database unless it was a critical for performance. This does not make it portable and does the performance of my product require it? It really comes down to the application there is not one big paint brush. We have all be around and get this. I would not likely design a solution that had the database and the application layers both containing the business logic. I have seen this and the unexpected behavior as assumptions are made on both ends of that spectrum. I like to keep it simple where I can. This all being said I think database minded folks should own DAO's. I think if your a database guy and you don't own the DAO's you are missing an opportunity to really make a difference and get more aligned with your development staff. Doesn't matter what code base DAO's are in it's a repetitive pattern that any database person can pick up. 

On Wed, May 4, 2016 at 12:29 PM, Szymon Lipiński <mabewlun@gmail.com> wrote:


On 4 May 2016 at 18:14, Will McCormick <wmccormick@gmail.com> wrote:
I agree it's typically political but so are most things business. Examples:  Companies buy other companies - You are using a competitors data store and want to replace it.  Company needs to compete with competitors and wants to reduce cost ... these are not technical requirements and it's certainly not vapor ideology. I have only worked for startups and have seen this happen at every company i have worked for, yes it is political but yes it happens. Smaller companies are more susceptible to it. 

The reality is somewhere in the middle as it often is. My point is you don't have to replace a million lines of code if you plan upfront. If you don't .. you do.


On Wed, May 4, 2016 at 11:29 AM, Uwe Schroeder <uwe@oss4u.com> wrote:

On Wed, May 04, 2016 11:05:25 AM Will McCormick wrote:

A reason to consider may be portability. What happens if I want to let my customer chose their data store or I just don't want to put all my eggs in one basket.Technically there are truths but you cannot ignore the business side either. If a we can exceed our performance requirements and keep things generic/portable this is the best of both worlds.I think this is the main reason people separate the business logic from the database. How many of you have ported databases between platforms? Or had multiple types of data stores in the same company?

I have been waiting for the portability argument for the last 20+ posts :-) Everyone who did any type of consulting/working in this field knows that latest the second argument from management is “portability”. I have yet to see anyone who really needed to move to a different database. If they did it usually is a political issue and not a technical one (uhh, we hired this new operations manager and MS SQL is so much better than postgresql …) Unless you develop a generic software to be sold to many clients, the choice of data storage is rarely a real concern unless someone who feels the urge to be important starts throwing words he read in a magazine at management. None of my clients ever questioned the database. They either had one which they wanted to use (i.e. they had a big iron IBM with DB2 on it plus a DBA who knew what he was doing) or they didn't care as long as it worked as expected and came with a maintenance contract of sorts.

If you're developing a web application, the least concern is portability (you're not going to replace the million lines of PHP either). The biggest concern should lie with data integrity and API's that protect your data and business logic so you can hire that cheap app development company from overseas your boss recommended (based on a spam email) without running the risk of compromising everything.

Uwe



I'm not sure that when a company buys another company they can just migrate the other database without any logic layer. The data is usually useless without the business layer which tells how to merge all the parts together to have a simple answer to a question like "do we have this in stock". And for such a migration that's not too important if we have the logic in database, or in some other layer. Of course it is always simpler to migrate a database treated like a CSV file, where all the logic (including constraints) is in an external application. But do we really want that?

On the other hand, when I was trying to store all my logic in a database, there was just one thing that made me hate it. Testing. Testing the procedures inside the database was not easy, not funny, and too much time consuming. 

--
    regards Szymon Lipiński

Re: Thoughts on "Love Your Database"

From
Szymon Lipiński
Date:


On 4 May 2016 at 19:09, Will McCormick <wmccormick@gmail.com> wrote:
I agree that it's not like turning on the light switch. And I'm not implying there isn't a logic layer between the database and the application. Based off my past experiences I would likely not put business logic in the database unless it was a critical for performance. This does not make it portable and does the performance of my product require it? It really comes down to the application there is not one big paint brush. We have all be around and get this. I would not likely design a solution that had the database and the application layers both containing the business logic. I have seen this and the unexpected behavior as assumptions are made on both ends of that spectrum. I like to keep it simple where I can. This all being said I think database minded folks should own DAO's. I think if your a database guy and you don't own the DAO's you are missing an opportunity to really make a difference and get more aligned with your development staff. Doesn't matter what code base DAO's are in it's a repetitive pattern that any database person can pick up. 

On Wed, May 4, 2016 at 12:29 PM, Szymon Lipiński <mabewlun@gmail.com> wrote:


On 4 May 2016 at 18:14, Will McCormick <wmccormick@gmail.com> wrote:
I agree it's typically political but so are most things business. Examples:  Companies buy other companies - You are using a competitors data store and want to replace it.  Company needs to compete with competitors and wants to reduce cost ... these are not technical requirements and it's certainly not vapor ideology. I have only worked for startups and have seen this happen at every company i have worked for, yes it is political but yes it happens. Smaller companies are more susceptible to it. 

The reality is somewhere in the middle as it often is. My point is you don't have to replace a million lines of code if you plan upfront. If you don't .. you do.


On Wed, May 4, 2016 at 11:29 AM, Uwe Schroeder <uwe@oss4u.com> wrote:

On Wed, May 04, 2016 11:05:25 AM Will McCormick wrote:

A reason to consider may be portability. What happens if I want to let my customer chose their data store or I just don't want to put all my eggs in one basket.Technically there are truths but you cannot ignore the business side either. If a we can exceed our performance requirements and keep things generic/portable this is the best of both worlds.I think this is the main reason people separate the business logic from the database. How many of you have ported databases between platforms? Or had multiple types of data stores in the same company?

I have been waiting for the portability argument for the last 20+ posts :-) Everyone who did any type of consulting/working in this field knows that latest the second argument from management is “portability”. I have yet to see anyone who really needed to move to a different database. If they did it usually is a political issue and not a technical one (uhh, we hired this new operations manager and MS SQL is so much better than postgresql …) Unless you develop a generic software to be sold to many clients, the choice of data storage is rarely a real concern unless someone who feels the urge to be important starts throwing words he read in a magazine at management. None of my clients ever questioned the database. They either had one which they wanted to use (i.e. they had a big iron IBM with DB2 on it plus a DBA who knew what he was doing) or they didn't care as long as it worked as expected and came with a maintenance contract of sorts.

If you're developing a web application, the least concern is portability (you're not going to replace the million lines of PHP either). The biggest concern should lie with data integrity and API's that protect your data and business logic so you can hire that cheap app development company from overseas your boss recommended (based on a spam email) without running the risk of compromising everything.

Uwe



I'm not sure that when a company buys another company they can just migrate the other database without any logic layer. The data is usually useless without the business layer which tells how to merge all the parts together to have a simple answer to a question like "do we have this in stock". And for such a migration that's not too important if we have the logic in database, or in some other layer. Of course it is always simpler to migrate a database treated like a CSV file, where all the logic (including constraints) is in an external application. But do we really want that?

On the other hand, when I was trying to store all my logic in a database, there was just one thing that made me hate it. Testing. Testing the procedures inside the database was not easy, not funny, and too much time consuming. 

--
    regards Szymon Lipiński


I also wouldn't keep the logic in a database. And the DAO layer is the best solution I know. The biggest problem I experienced was that there was no DBA in a team, management didn't see any problem with that, and the DAO layer was managed by random programmers who didn't want to learn databases. The results were mainly two: slow development (due to too many bugs), and slow application (due to bad queries).

It seems like there is no problem with storing logic anywhere, the problem is with having someone who knows how to write it.


--
    regards Szymon Lipiński

Re: Thoughts on "Love Your Database"

From
Will McCormick
Date:
I 100% agree with you. It's always been a problem but it is up to us to take ownership and provide value. Some would be surprising shocked how simple it is to manage the Data access layer once the framework is in place regardless of what it is written in. For the same reasons you wouldn't typically have Application Developers configuring your production disks for high performance... why would you ever have them access the database inefficiently? There is an assumption designers are good at SQL or at least know it ... I challenge you to flip that around and learn the Data Access Layer.  Companies do not knowingly spend money on hardware to have it consumed by inefficient data access? No executive signs up to increase the TCO and reduce profit margins when they could be making more money? But this is far to often the case and the root cause is they did not have the right tool (pun not intended) for the job. 

On Wed, May 4, 2016 at 1:33 PM, Szymon Lipiński <mabewlun@gmail.com> wrote:


On 4 May 2016 at 19:09, Will McCormick <wmccormick@gmail.com> wrote:
I agree that it's not like turning on the light switch. And I'm not implying there isn't a logic layer between the database and the application. Based off my past experiences I would likely not put business logic in the database unless it was a critical for performance. This does not make it portable and does the performance of my product require it? It really comes down to the application there is not one big paint brush. We have all be around and get this. I would not likely design a solution that had the database and the application layers both containing the business logic. I have seen this and the unexpected behavior as assumptions are made on both ends of that spectrum. I like to keep it simple where I can. This all being said I think database minded folks should own DAO's. I think if your a database guy and you don't own the DAO's you are missing an opportunity to really make a difference and get more aligned with your development staff. Doesn't matter what code base DAO's are in it's a repetitive pattern that any database person can pick up. 

On Wed, May 4, 2016 at 12:29 PM, Szymon Lipiński <mabewlun@gmail.com> wrote:


On 4 May 2016 at 18:14, Will McCormick <wmccormick@gmail.com> wrote:
I agree it's typically political but so are most things business. Examples:  Companies buy other companies - You are using a competitors data store and want to replace it.  Company needs to compete with competitors and wants to reduce cost ... these are not technical requirements and it's certainly not vapor ideology. I have only worked for startups and have seen this happen at every company i have worked for, yes it is political but yes it happens. Smaller companies are more susceptible to it. 

The reality is somewhere in the middle as it often is. My point is you don't have to replace a million lines of code if you plan upfront. If you don't .. you do.


On Wed, May 4, 2016 at 11:29 AM, Uwe Schroeder <uwe@oss4u.com> wrote:

On Wed, May 04, 2016 11:05:25 AM Will McCormick wrote:

A reason to consider may be portability. What happens if I want to let my customer chose their data store or I just don't want to put all my eggs in one basket.Technically there are truths but you cannot ignore the business side either. If a we can exceed our performance requirements and keep things generic/portable this is the best of both worlds.I think this is the main reason people separate the business logic from the database. How many of you have ported databases between platforms? Or had multiple types of data stores in the same company?

I have been waiting for the portability argument for the last 20+ posts :-) Everyone who did any type of consulting/working in this field knows that latest the second argument from management is “portability”. I have yet to see anyone who really needed to move to a different database. If they did it usually is a political issue and not a technical one (uhh, we hired this new operations manager and MS SQL is so much better than postgresql …) Unless you develop a generic software to be sold to many clients, the choice of data storage is rarely a real concern unless someone who feels the urge to be important starts throwing words he read in a magazine at management. None of my clients ever questioned the database. They either had one which they wanted to use (i.e. they had a big iron IBM with DB2 on it plus a DBA who knew what he was doing) or they didn't care as long as it worked as expected and came with a maintenance contract of sorts.

If you're developing a web application, the least concern is portability (you're not going to replace the million lines of PHP either). The biggest concern should lie with data integrity and API's that protect your data and business logic so you can hire that cheap app development company from overseas your boss recommended (based on a spam email) without running the risk of compromising everything.

Uwe



I'm not sure that when a company buys another company they can just migrate the other database without any logic layer. The data is usually useless without the business layer which tells how to merge all the parts together to have a simple answer to a question like "do we have this in stock". And for such a migration that's not too important if we have the logic in database, or in some other layer. Of course it is always simpler to migrate a database treated like a CSV file, where all the logic (including constraints) is in an external application. But do we really want that?

On the other hand, when I was trying to store all my logic in a database, there was just one thing that made me hate it. Testing. Testing the procedures inside the database was not easy, not funny, and too much time consuming. 

--
    regards Szymon Lipiński


I also wouldn't keep the logic in a database. And the DAO layer is the best solution I know. The biggest problem I experienced was that there was no DBA in a team, management didn't see any problem with that, and the DAO layer was managed by random programmers who didn't want to learn databases. The results were mainly two: slow development (due to too many bugs), and slow application (due to bad queries).

It seems like there is no problem with storing logic anywhere, the problem is with having someone who knows how to write it.


--
    regards Szymon Lipiński

Re: Thoughts on "Love Your Database"

From
Szymon Lipiński
Date:


On 4 May 2016 at 20:20, Will McCormick <wmccormick@gmail.com> wrote:
I 100% agree with you. It's always been a problem but it is up to us to take ownership and provide value. Some would be surprising shocked how simple it is to manage the Data access layer once the framework is in place regardless of what it is written in. For the same reasons you wouldn't typically have Application Developers configuring your production disks for high performance... why would you ever have them access the database inefficiently? There is an assumption designers are good at SQL or at least know it ... I challenge you to flip that around and learn the Data Access Layer.  Companies do not knowingly spend money on hardware to have it consumed by inefficient data access? No executive signs up to increase the TCO and reduce profit margins when they could be making more money? But this is far to often the case and the root cause is they did not have the right tool (pun not intended) for the job. 

On Wed, May 4, 2016 at 1:33 PM, Szymon Lipiński <mabewlun@gmail.com> wrote:


On 4 May 2016 at 19:09, Will McCormick <wmccormick@gmail.com> wrote:
I agree that it's not like turning on the light switch. And I'm not implying there isn't a logic layer between the database and the application. Based off my past experiences I would likely not put business logic in the database unless it was a critical for performance. This does not make it portable and does the performance of my product require it? It really comes down to the application there is not one big paint brush. We have all be around and get this. I would not likely design a solution that had the database and the application layers both containing the business logic. I have seen this and the unexpected behavior as assumptions are made on both ends of that spectrum. I like to keep it simple where I can. This all being said I think database minded folks should own DAO's. I think if your a database guy and you don't own the DAO's you are missing an opportunity to really make a difference and get more aligned with your development staff. Doesn't matter what code base DAO's are in it's a repetitive pattern that any database person can pick up. 

On Wed, May 4, 2016 at 12:29 PM, Szymon Lipiński <mabewlun@gmail.com> wrote:


On 4 May 2016 at 18:14, Will McCormick <wmccormick@gmail.com> wrote:
I agree it's typically political but so are most things business. Examples:  Companies buy other companies - You are using a competitors data store and want to replace it.  Company needs to compete with competitors and wants to reduce cost ... these are not technical requirements and it's certainly not vapor ideology. I have only worked for startups and have seen this happen at every company i have worked for, yes it is political but yes it happens. Smaller companies are more susceptible to it. 

The reality is somewhere in the middle as it often is. My point is you don't have to replace a million lines of code if you plan upfront. If you don't .. you do.


On Wed, May 4, 2016 at 11:29 AM, Uwe Schroeder <uwe@oss4u.com> wrote:

On Wed, May 04, 2016 11:05:25 AM Will McCormick wrote:

A reason to consider may be portability. What happens if I want to let my customer chose their data store or I just don't want to put all my eggs in one basket.Technically there are truths but you cannot ignore the business side either. If a we can exceed our performance requirements and keep things generic/portable this is the best of both worlds.I think this is the main reason people separate the business logic from the database. How many of you have ported databases between platforms? Or had multiple types of data stores in the same company?

I have been waiting for the portability argument for the last 20+ posts :-) Everyone who did any type of consulting/working in this field knows that latest the second argument from management is “portability”. I have yet to see anyone who really needed to move to a different database. If they did it usually is a political issue and not a technical one (uhh, we hired this new operations manager and MS SQL is so much better than postgresql …) Unless you develop a generic software to be sold to many clients, the choice of data storage is rarely a real concern unless someone who feels the urge to be important starts throwing words he read in a magazine at management. None of my clients ever questioned the database. They either had one which they wanted to use (i.e. they had a big iron IBM with DB2 on it plus a DBA who knew what he was doing) or they didn't care as long as it worked as expected and came with a maintenance contract of sorts.

If you're developing a web application, the least concern is portability (you're not going to replace the million lines of PHP either). The biggest concern should lie with data integrity and API's that protect your data and business logic so you can hire that cheap app development company from overseas your boss recommended (based on a spam email) without running the risk of compromising everything.

Uwe



I'm not sure that when a company buys another company they can just migrate the other database without any logic layer. The data is usually useless without the business layer which tells how to merge all the parts together to have a simple answer to a question like "do we have this in stock". And for such a migration that's not too important if we have the logic in database, or in some other layer. Of course it is always simpler to migrate a database treated like a CSV file, where all the logic (including constraints) is in an external application. But do we really want that?

On the other hand, when I was trying to store all my logic in a database, there was just one thing that made me hate it. Testing. Testing the procedures inside the database was not easy, not funny, and too much time consuming. 

--
    regards Szymon Lipiński


I also wouldn't keep the logic in a database. And the DAO layer is the best solution I know. The biggest problem I experienced was that there was no DBA in a team, management didn't see any problem with that, and the DAO layer was managed by random programmers who didn't want to learn databases. The results were mainly two: slow development (due to too many bugs), and slow application (due to bad queries).

It seems like there is no problem with storing logic anywhere, the problem is with having someone who knows how to write it.


--
    regards Szymon Lipiński


You forgot that it is intended, there is the mantra "developers are expensive, hardware is cheap". 

--
    regards Szymon Lipiński

Re: Thoughts on "Love Your Database"

From
Guyren Howe
Date:
On May 4, 2016, at 11:59 , Paul Jungwirth <pj@illuminatedcomputing.com> wrote:
>
> I think teaching this is a different thing than just teaching SQL syntax. I haven't seen it written about a lot. It
mustbe somewhere, but any book encouraging "outsiders" to use more SQL could benefit from giving them direction like
that.

I've never seen relational databases explained properly for beginners.

I did a pretty successful boot camp two-week database course where it was heavily built around set operations. I
startedwith a simple query on a table, then we went into all the cool things you could do to combine queries using
UNION,INTERSECT and EXCEPT. To this day, I hardly ever see set operations used in SQL, and oftentimes when you have a
hardquery to write, set operations are the natural expression. Anyhow. 

Re: Thoughts on "Love Your Database"

From
Will McCormick
Date:
Yeah but your already paying for a developer ...

On Wed, May 4, 2016 at 2:36 PM, Szymon Lipiński <mabewlun@gmail.com> wrote:


On 4 May 2016 at 20:20, Will McCormick <wmccormick@gmail.com> wrote:
I 100% agree with you. It's always been a problem but it is up to us to take ownership and provide value. Some would be surprising shocked how simple it is to manage the Data access layer once the framework is in place regardless of what it is written in. For the same reasons you wouldn't typically have Application Developers configuring your production disks for high performance... why would you ever have them access the database inefficiently? There is an assumption designers are good at SQL or at least know it ... I challenge you to flip that around and learn the Data Access Layer.  Companies do not knowingly spend money on hardware to have it consumed by inefficient data access? No executive signs up to increase the TCO and reduce profit margins when they could be making more money? But this is far to often the case and the root cause is they did not have the right tool (pun not intended) for the job. 

On Wed, May 4, 2016 at 1:33 PM, Szymon Lipiński <mabewlun@gmail.com> wrote:


On 4 May 2016 at 19:09, Will McCormick <wmccormick@gmail.com> wrote:
I agree that it's not like turning on the light switch. And I'm not implying there isn't a logic layer between the database and the application. Based off my past experiences I would likely not put business logic in the database unless it was a critical for performance. This does not make it portable and does the performance of my product require it? It really comes down to the application there is not one big paint brush. We have all be around and get this. I would not likely design a solution that had the database and the application layers both containing the business logic. I have seen this and the unexpected behavior as assumptions are made on both ends of that spectrum. I like to keep it simple where I can. This all being said I think database minded folks should own DAO's. I think if your a database guy and you don't own the DAO's you are missing an opportunity to really make a difference and get more aligned with your development staff. Doesn't matter what code base DAO's are in it's a repetitive pattern that any database person can pick up. 

On Wed, May 4, 2016 at 12:29 PM, Szymon Lipiński <mabewlun@gmail.com> wrote:


On 4 May 2016 at 18:14, Will McCormick <wmccormick@gmail.com> wrote:
I agree it's typically political but so are most things business. Examples:  Companies buy other companies - You are using a competitors data store and want to replace it.  Company needs to compete with competitors and wants to reduce cost ... these are not technical requirements and it's certainly not vapor ideology. I have only worked for startups and have seen this happen at every company i have worked for, yes it is political but yes it happens. Smaller companies are more susceptible to it. 

The reality is somewhere in the middle as it often is. My point is you don't have to replace a million lines of code if you plan upfront. If you don't .. you do.


On Wed, May 4, 2016 at 11:29 AM, Uwe Schroeder <uwe@oss4u.com> wrote:

On Wed, May 04, 2016 11:05:25 AM Will McCormick wrote:

A reason to consider may be portability. What happens if I want to let my customer chose their data store or I just don't want to put all my eggs in one basket.Technically there are truths but you cannot ignore the business side either. If a we can exceed our performance requirements and keep things generic/portable this is the best of both worlds.I think this is the main reason people separate the business logic from the database. How many of you have ported databases between platforms? Or had multiple types of data stores in the same company?

I have been waiting for the portability argument for the last 20+ posts :-) Everyone who did any type of consulting/working in this field knows that latest the second argument from management is “portability”. I have yet to see anyone who really needed to move to a different database. If they did it usually is a political issue and not a technical one (uhh, we hired this new operations manager and MS SQL is so much better than postgresql …) Unless you develop a generic software to be sold to many clients, the choice of data storage is rarely a real concern unless someone who feels the urge to be important starts throwing words he read in a magazine at management. None of my clients ever questioned the database. They either had one which they wanted to use (i.e. they had a big iron IBM with DB2 on it plus a DBA who knew what he was doing) or they didn't care as long as it worked as expected and came with a maintenance contract of sorts.

If you're developing a web application, the least concern is portability (you're not going to replace the million lines of PHP either). The biggest concern should lie with data integrity and API's that protect your data and business logic so you can hire that cheap app development company from overseas your boss recommended (based on a spam email) without running the risk of compromising everything.

Uwe



I'm not sure that when a company buys another company they can just migrate the other database without any logic layer. The data is usually useless without the business layer which tells how to merge all the parts together to have a simple answer to a question like "do we have this in stock". And for such a migration that's not too important if we have the logic in database, or in some other layer. Of course it is always simpler to migrate a database treated like a CSV file, where all the logic (including constraints) is in an external application. But do we really want that?

On the other hand, when I was trying to store all my logic in a database, there was just one thing that made me hate it. Testing. Testing the procedures inside the database was not easy, not funny, and too much time consuming. 

--
    regards Szymon Lipiński


I also wouldn't keep the logic in a database. And the DAO layer is the best solution I know. The biggest problem I experienced was that there was no DBA in a team, management didn't see any problem with that, and the DAO layer was managed by random programmers who didn't want to learn databases. The results were mainly two: slow development (due to too many bugs), and slow application (due to bad queries).

It seems like there is no problem with storing logic anywhere, the problem is with having someone who knows how to write it.


--
    regards Szymon Lipiński


You forgot that it is intended, there is the mantra "developers are expensive, hardware is cheap". 

--
    regards Szymon Lipiński

Re: Thoughts on "Love Your Database"

From
Andrew Sullivan
Date:
On Tue, May 03, 2016 at 11:11:06PM -0500, Guyren Howe wrote:
> I've long been frustrated with how most web developers I meet have no idea how to use an SQL database properly. I
thinkI'm going to write a book called Love Your Database, aimed at web developers, that explains how to make their apps
betterby leveraging the power of SQL in general, and Postgres in particular. 
>

For whatever it's worth, more than 10 years ago I reviewed (for a
publisher) a book along these lines.  To my knowledge, it never got
published, though I thought it was quite good.

The problem is that most development on the web does not, as far as I
can tell, regard the development as what I'd think of as a real
database-backed system.  An awful lot of web systems, in particular,
treat the database as a fancy and expensive but somewhat portable
filesystem.  (This is even more true now that SQL isn't as ubiquitous
as it once was.)

I still think this is worth promoting, but it seems to me that
attempting to create some sort of buzz around these ideas at various
developer community events.  But there are three things that I think
would help make this work for more developers:

    1.  This will make your application faster.  (This needs to be
    proved -- I agree with the "benchmarks" point in the original
    post.)

    2.  This will make your time to ship/continuous integration/time
    to fix bugs shorter.  This is harder to prove, but it's an
    important value for most developers (and developer managers).

    3.  This is way cooler than $x.

(3) is a distant 3d, but my experience of managing less-experienced
developers who go to conferences suggest that it's a good way to get
people interested.

I think there's something that we're going to have to accept, however,
and that's that there are way more application coders than there are
people who really get database systems.  Fixing this problem requires
years of efforts.

Best regards,

A

--
Andrew Sullivan
ajs@crankycanuck.ca


Re: Thoughts on "Love Your Database"

From
Kus
Date:

On May 4, 2016 4:56:23 PM EDT, Andrew Sullivan <ajs@crankycanuck.ca> wrote:
>I think there's something that we're going to have to accept, however,
>and that's that there are way more application coders than there are
>people who really get database systems.  Fixing this problem requires
>years of efforts.

I don't really get database systems. I remember this conversation with my professor who said we should use ASCII and
notUnicode because we won't need anything beyond the ASCII characters (this was on an Oracle database). As an
applicationdeveloper, I don't know how I'd keep up with the right way to do things(TM) as rdbms keep evolving.  

:(


Re: Thoughts on "Love Your Database"

From
Vincent Veyron
Date:
On Tue, 3 May 2016 23:11:06 -0500
Guyren Howe <guyren@gmail.com> wrote:

> Any other thoughts?

I like this quote from Fred Brooks :

`Show me your code and conceal your data structures, and I shall continue to be mystified. Show me your data
structures,and I won't usually need your code; it'll be obvious.' 

It seems to be confirmed by some rather qualified people :

http://lwn.net/Articles/193245/

I write management applications for businesses, and give _a lot_ of care to the database structure. I find that the
numberof lines of code that need to be written is strictly inversely correlated to the appropriateness of the database
design(meaning that the better the database structure, the lesser code is needed). 

Knowing about the many fine functions Postgresql offers also helps, of course.

--
                    Bien à vous, Vincent Veyron

https://libremen.com
Logiciels de gestion, libres


Re: Thoughts on "Love Your Database"

From
"dandl"
Date:
> From: Pierre Chevalier Géologue [mailto:pierrechevaliergeol@free.fr]
> ...
> > Then I think you've seriously misunderstood. Most people can indeed
> >learn to write basic SQL queries, but those are
> >(obviously) not what I'm talking about.
> >
> > To write the business logic of a significant application entirely in
> >SQL requires PLSQL (or in other dialects, whatever passes for SQL/PSM).
> >It means writing an entire data access layer as a set of stored
> >procedures, with a substantial set of special functions, types,
> >triggers and so on. No beginner and few experts have the skills
> >required to do that in SQL, and then debug that code on the server.
>
> All right, I understand better now.  I think I also totally missed your
> point, sorry...
> I'll give a look at andl.

I hope you do. Please feel free to contact me with any comments, suggestions, etc.

I have not completed the Postgres implementation -- probably another couple of weeks -- but in-memory and Sqlite are
there.

Bonne chance!

Regards
David M Bennett FACS

Andl - A New Database Language - andl.org







Re: Thoughts on "Love Your Database"

From
"Mike Sofen"
Date:
>From: Vincent Veyron   Sent: Wednesday, May 04, 2016 3:35 PM

>I write management applications for businesses, and give _a lot_ of care to
the database structure.
>I find that the number of lines of code that need to be written is strictly
inversely correlated to the
 >appropriateness of the database design (meaning that the better the
database structure, the lesser
>code is needed).

>Knowing about the many fine functions Postgresql offers also helps, of
course.
>                    Bien à vous, Vincent Veyron


An inverse corollary is also true, imo: encountering demands for exotic,
wild functions, cursors and code constructs (like triggers calling triggers
or frankly, triggers in general), is nearly always an indication of poor
database design.  I'm not talking about windowing functions or json or CTEs,
btw.

Postgres and mysql have piles and piles of functions that I will never use
and can't even imagine scenarios in which to use them.  So I agree 100% -
it's all about the database (design).   BTW, I'm currently
designing/building OLTP databases for use in genomics research (using
Postgres)...that's big data...where there is zero tolerance for slack db
design that could cause scalability or performance issues.  My stored
functions are...relatively simple.

Mike Sofen  (San Diego, CA USA)




Re: Thoughts on "Love Your Database"

From
"Mike Sofen"
Date:

From: dandl    Sent: Wednesday, May 04, 2016 5:05 PM
To: 'Pierre Chevalier Géologue' <pierrechevaliergeol@free.fr>

> From: Pierre Chevalier Géologue [mailto:pierrechevaliergeol@free.fr]

> ...

> > Then I think you've seriously misunderstood. Most people can indeed

> >learn to write basic SQL queries, but those are

> >(obviously) not what I'm talking about.

> >

> > To write the business logic of a significant application entirely in

> >SQL requires PLSQL (or in other dialects, whatever passes for SQL/PSM).

> >It means writing an entire data access layer as a set of stored

> >procedures, with a substantial set of special functions, types,

> >triggers and so on. No beginner and few experts have the skills

> >required to do that in SQL, and then debug that code on the server.

>

> All right, I understand better now.  I think I also totally missed

> your point, sorry...

> I'll give a look at andl.

 

I hope you do. Please feel free to contact me with any comments, suggestions, etc.

 

I have not completed the Postgres implementation -- probably another couple of weeks –

but in-memory and Sqlite are there.

 

Bonne chance!

 

Regards

David M Bennett FACS

=======================

 

I disagree.  I’ve worked as database architect/engineer at a number of large and small firms in various verticals (healthcare, financials, insurance, aerospace, telecom, etc), and created complete database api’s via stored procs/stored functions, some of which were quite complex.  I’ve found that a mid-level database developer, with modest coaching and good comments in the code, can pick up the code, support it and even enhance it.  So the notion that experts can only write and maintain quality code isn’t valid in my experience.

 

There is definitely a difference in capability/velocity/solution  solving between junior, mid-level and senior developers, but that isn’t a deal killer, it’s just something that needs to be managed and accounted for. 

 

One reason for a database api is that ORMs have proved themselves incapable of proper scaling and ACID compliance, where stored procs/functions are capable of leveraging the massive set-based relational power of the underlying engine, and leverage efficient functionalities like windowing functions.

 

So I guess you’d say I’m in the entirely opposite camp, since it’s proven to be such an effective solution architecture for many applications that leverage relational database engines.

 

Mike Sofen  (San Diego, CA  USA)

Re: Thoughts on "Love Your Database"

From
"dandl"
Date:

From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Mike Sofen

I disagree.  I’ve worked as database architect/engineer at a number of large and small firms in various verticals (healthcare, financials, insurance, aerospace, telecom, etc), and created complete database api’s via stored procs/stored functions, some of which were quite complex.  I’ve found that a mid-level database developer, with modest coaching and good comments in the code, can pick up the code, support it and even enhance it.  So the notion that experts can only write and maintain quality code isn’t valid in my experience.

 

The original proposition was that this (a stored procedure API) was such a simple task any beginner could do it with ease. My view is that it is a job for a seasoned application developer with SQL skills that go well beyond simple queries. I don’t see much disagreement here.

 

There is definitely a difference in capability/velocity/solution  solving between junior, mid-level and senior developers, but that isn’t a deal killer, it’s just something that needs to be managed and accounted for. 

 

One reason for a database api is that ORMs have proved themselves incapable of proper scaling and ACID compliance, where stored procs/functions are capable of leveraging the massive set-based relational power of the underlying engine, and leverage efficient functionalities like windowing functions.

 

I agree absolutely. ORMs exists because of a strong desire to do business logic coding in the big 5 OO languages and not in whatever dialect of SQL may or may not be available on the RDBMS in question. The whole point of Andl is to make set-based relational logic including user-written accumulation functions, recursion (CTE) and ordered queries (windowing) available and accessible to ordinary developers, and totally avoid the need for an ORM.

 

So I guess you’d say I’m in the entirely opposite camp, since it’s proven to be such an effective solution architecture for many applications that leverage relational database engines.

 

It is indeed a totally effective architecture. If you haven’t already read it I strongly recommend http://thehelsinkideclaration.blogspot.com.au/2009/03/window-on-data-applications.html fora detailed description. It’s effective, but it sure ain’t easy, especially if you value portability between RDBMS. Andl aims to fill that gap: make that architecture accessible to all.

 

I don’t think we’re in different camps at all.

 

Regards

David M Bennett FACS


Andl - A New Database Language - andl.org

 

Re: Thoughts on "Love Your Database"

From
George Neuner
Date:
On Tue, 3 May 2016 23:11:06 -0500, Guyren Howe <guyren@gmail.com>
wrote:

>I've long been frustrated with how most web developers I meet
>have no idea how to use an SQL database properly. I think I'm
>going to write a book called Love Your Database, aimed at web
>developers, that explains how to make their apps better by
>leveraging the power of SQL in general, and Postgres in particular.
>
>I'm thinking of a section on features of SQL most folks don't know
>about (CTEs are *way* to hell at the top of that list, but also
>EXCEPT/INTERSECT and window functions), but much of the book
>would be about how to do things server side. Benchmarks showing
>how much faster this can be, but mostly techniques — stored
>procedures/triggers/rules, views.
>
>I asked a colleague about the advice I often hear stated but seldom
>justified, that one shouldn't put business rules in the database. He
>offered that server-side code can be hard to debug.
>
>I'm sure many here would love to see such a book published,
>maybe some talks on the topic given.

I think such a book would be wonderful.  Unfortunately, I doubt many
web coders would take the time to read it.

You might want a chapter or 3 on Model-View-Controller ... where it is
appropriate and where it isn't.  I've seen some truly spectacular
backflips done by code trying to shoehorn uncooperative data models
into MVC.


>What might I cover that I haven't mentioned? What are the usual
>objections to server-side code and how can they be met? When
>*are* they justified and what should the criteria be to put code in
>Postgres? Any other thoughts? Any other websites or books on
>the topic I might consult?

FWIW: I have a master degree in data modeling.  I design databases,
and when necessary write web facing middleware for them.

The usual objection to stored code is highly conditional queries.  For
example, my most recent web project has a search which is ~100 lines
of SQL with 7 CTEs, 5 of which are executed conditionally depending on
user input.  This kind of dynamic code is painful to write in most SQL
dialects.

I compose such queries in middleware preferentially because I can use
languages better suited to complex string manipulation.  And yes, I am
aware of injection: SQL may be composed dynamically, but user input is
/never/ spliced - it always is passed via SQL parameters.

I am aware that Postgresql has other languages available as
extensions.  Some of them would do the job - though I think not as
nicely as my goto language: Racket (a Scheme dialect).
[Yes, I know Guile (Scheme) is one of the extension languages.]

The code wouldn't be any less complicated for being resident in the
DBMS, and I doubt it would be much faster: my middleware is always
either co-located with the DBMS, or on the same LAN if working with a
cluster.

I draw the line at giving web clients direct access to a database -
any web facing system I design always involves mediation via
middleware.   IME it is the copying/conversion of data to/from the
HTTP interface that ultimately limits performance, so where to put the
database code largely is a judgement call.

YMMV,
George

Re: Thoughts on "Love Your Database"

From
Szymon Lipiński
Date:


On 4 May 2016 at 23:52, Kus <spamkushal@gmail.com> wrote:


On May 4, 2016 4:56:23 PM EDT, Andrew Sullivan <ajs@crankycanuck.ca> wrote:
>I think there's something that we're going to have to accept, however,
>and that's that there are way more application coders than there are
>people who really get database systems.  Fixing this problem requires
>years of efforts.

I don't really get database systems. I remember this conversation with my professor who said we should use ASCII and not Unicode because we won't need anything beyond the ASCII characters (this was on an Oracle database). As an application developer, I don't know how I'd keep up with the right way to do things(TM) as rdbms keep evolving.

:(


At one of my first jobs my boss used to tell two truths: "The database will always be inconsistent" and "Indexes are useless, they don't give anything except for slowing down the database". So, don't believe in everything "wise" people say, just think, and check on your own. 


--
    regards Szymon Lipiński

Re: Thoughts on "Love Your Database"

From
Francisco Olarte
Date:
On Thu, May 5, 2016 at 12:34 AM, Vincent Veyron <vv.lists@wanadoo.fr> wrote:
> I like this quote from Fred Brooks :
>
> `Show me your code and conceal your data structures, and I shall continue to be mystified. Show me your data
structures,and I won't usually need your code; it'll be obvious.' 

I remembered it as 'Show me your tables,...", which looks even more
applicable in this list. A quick googgle search for SMYT did in fact
return a link to wikiquote at the top, it says "Show me your
flowcharts and conceal your tables, and I shall continue to be
mystified. Show me your tables, and I won’t usually need your
flowcharts; they’ll be obvious. " from TMMM, so its normal I remember
it that way ( I still own it and reread some chunks every couple of
years. )

Francisco Olarte.


Re: Thoughts on "Love Your Database"

From
Achilleas Mantzios
Date:
On 04/05/2016 15:55, Szymon Lipiński wrote:

at my previous jobs I was working with many programmers, and almost none of them understood SQL. The problem was even deeper. They didn't want to learn it. When I was working among java programmers, I noticed that they hated SQL, but there was no problem with learning HQL, which in fact is quite similar. I really have no idea why it is like that.


Similar here. IMHO it is called "job trends hype". Look at all the linkedin ads, less than 1% is about Pgsql/DBs, 99% is about app coders. Ok rough numbers, but it reflects reality. One of my past programmers (a fine kid always looking to learn) now writes IOS and Android apps in another country. Another one who didn't do much well with SQL, but rock-star programmer otherwise, now writes javascript in another company.

--

    regards Szymon Lipiński


-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt

Re: Thoughts on "Love Your Database"

From
Marc Mamin
Date:
>What might I cover that I haven't mentioned?
>What are the usual objections to server-side code and how can they be met?
>When *are* they justified and what should the criteria be to put code in Postgres? Any other thoughts?

Hi,
For my point of view, scalability considerations and possible performance gains are the key arguments to decide where
toput things.  
If a project may end up with tens of application servers connected to a single database, then you should let most of
thework on the application side.  
But to discharge the database, you also have to keep transactions as short as possible. So if some logic process
requiresmany back and forth within a single transaction, then it may make sense to implement it on the DB side; most
developpersI'm working with are resistent to this aspect.  
ORM layers are usefull, but nasty as they transform the database into a blackbox. I guess this can be a major reason
whydevelopers don't care for the SQL side. Testing should include some monitoring of the DB activity, which often
happensway too late. 

I try since years to convince my colleagues, that application code doesn't matter ;-) What counts are the data and how
theyare arranged within the DB. Therefore they should put more focus on them, rather then think in OOM. 

That book is a great idea. A collection of bad code example and the SQL equivalents, strengthend with runtimes figures,
mayhelp move some minds 

best regards,
Marc Mamin

Re: Thoughts on "Love Your Database"

From
Pierre Chevalier Géologue
Date:
Hello,

(sorry for delay, I've been traveling)

Le 04/05/2016 17:08, John McKown a écrit :
>>>> ...
>>>>         ​Allowing PHBs direct access t​o company data is a nasty thing.
>>>
>>>     Sorry, what is a PHB?  Our friend google didn't help me much on this
>>>     matter.
>
>> ​Ah. Sorry. PHB is a "Pointy Haired Boss" and is a reference to the
>> comic "Dilbert". Dilbert is a engineer who works for a boss who is a
>> complete idiot & has his hair moussed up at the sides (I guess it is
>> moussed).

Le 04/05/2016 17:05, Steve Crawford a écrit :
> Perhaps a bit US centric but PHB = Pointy Haired Boss. See the boss in
> "Dilbert".

Alright, got it, thanks.
I admire Dilbert; I've had bosses like PHB...


>> ...
>>     Hm.  Sounds familiar...
>>     I usually call "excelitis" a sort of mental disease related to a use
>>     and abuse of Excel, up to the point where one cannot imagine data
>>     which is *not* in a table-like array.  And they think that they do
>>     Relational Database Management...  In the 1990's, I met many-many
>>     deeply sick persons.  I had been infected for a while, I must confess.
>
> ​Yes, I keep reading in another forum about how to interface the R
> language so that the users can continue to input data into Excel, but
> then have it run a R language script to produce some output. So many
> there are trying to use Excel as their "user interface" because it is
> just about all the user knows.

Well, that could be a good way to pull them out of excel: once they will
realize that there is no way that they can do what R does with macros
and formulas (yes, they will try hard to get rid of R, I'm sure...), it
may open up their mind and consider other ways of looking at data than
mere two-dimensional tables...



> I had a manager, long ago, who used a Lotus 1-2-3​ spreadsheet to contain
> all his memos. I was glassy eyed in disbelief.

Well...  I did use 1-2-3 as a sort-of database (I was young... bad
excuse).  And also, I had used Excel to produce final reports, with
plenty of graphics, I used the vector editing tools a lot to make fancy
figures...
Hm.  Long time ago.


> He also would use his hand calculator to add up the numbers
> in the spreadsheet to be sure that the summation function in the
> spreadsheet didn't make a mistake. <shudder/>

Uh-oh.  This is worrying.  But it makes me think of a famous excel bug,
where you had something like 1 - 1 = 2...  Maybe your boss was actually
very wise (and paranoid)?...

À+
Pierre
--
____________________________________________________________________________
Pierre Chevalier
PChGEI: Pierre Chevalier Géologue Et Informaticien
Partenaire DALIBO
     Mesté Duran
     32100 Condom
   Tél+fax  :    09 75 27 45 62
                 06 37 80 33 64
   Émail  :   pierrechevaliergeolCHEZfree.fr
   icq#   :   10432285
   jabber: pierre.chevalier1967@jabber.fr
   http://pierremariechevalier.free.fr/pierre_chevalier_geologue
____________________________________________________________________________


Re: Thoughts on "Love Your Database"

From
Pierre Chevalier Géologue
Date:
Hi,
Le 04/05/2016 17:55, Alban Hertroys a écrit :
> On 4 May 2016 at 17:08, John McKown <john.archie.mckown@gmail.com> wrote:
>> I had a manager, long ago, who used a Lotus 1-2-3 spreadsheet to
>> contain all his memos. I was glassy eyed in disbelief. He also would use his
>> hand calculator to add up the numbers in the spreadsheet to be sure that the
>> summation function in the spreadsheet didn't make a mistake. <shudder/>
>
> That still happens - we have a few live examples around in this
> company. Unfortunately they're not caged and there's no sign "Do not
> feed the managers". Admittedly, they're using Excel instead of
> Lotus-1-2-3, but that's the only difference.

;-D


Another step (forward obviously) for these fellows is to use MSAccess.
Much better, yes.  But, still...

On this matter, I hear *very* often from such guys that the only
reproach they have to PostgreSQL is that it does not come with a slick
GUI like Access.  PGAdmin does not suit their needs at all: they want to
design their forms, directly write into the tables by using quick'n
easy/dirty copy/paste from/to their Excel (yes, it is still lying
around).  I understand them, somehow.
There are a few tools around, many proprietary ones, some Free/Libre
ones, but they are still looking for a sort of Holy Grail that would
definitely convince them.  A standard client tool that would come with
any PostgreSQL installation would please them.  Some sort of psqlGUI, I
guess.

Something to think about...  Maybe it would more suitable into
"advocacy" than here in "general", though.

À+
Pierre
--
____________________________________________________________________________
Pierre Chevalier
PChGEI: Pierre Chevalier Géologue Et Informaticien
Partenaire DALIBO
     Mesté Duran
     32100 Condom
   Tél+fax  :    09 75 27 45 62
                 06 37 80 33 64
   Émail  :   pierrechevaliergeolCHEZfree.fr
   icq#   :   10432285
   jabber: pierre.chevalier1967@jabber.fr
   http://pierremariechevalier.free.fr/pierre_chevalier_geologue
____________________________________________________________________________


Re: Thoughts on "Love Your Database"

From
John R Pierce
Date:
On 5/17/2016 1:34 AM, Pierre Chevalier Géologue wrote:

On this matter, I hear *very* often from such guys that the only reproach they have to PostgreSQL is that it does not come with a slick GUI like Access.

Access is a lot more than a slick GUI, its a rapid application development system based on VisualBasic.



-- 
john r pierce, recycling bits in santa cruz

Re: Thoughts on "Love Your Database"

From
Geoff Winkless
Date:
On 17 May 2016 at 09:34, Pierre Chevalier Géologue
<pierrechevaliergeol@free.fr> wrote:
> On this matter, I hear *very* often from such guys that the only reproach
> they have to PostgreSQL is that it does not come with a slick GUI like
> Access.  PGAdmin does not suit their needs at all: they want to design their
> forms, directly write into the tables by using quick'n easy/dirty copy/paste
> from/to their Excel (yes, it is still lying around).  I understand them,
> somehow.
> There are a few tools around, many proprietary ones, some Free/Libre ones,
> but they are still looking for a sort of Holy Grail that would definitely
> convince them.  A standard client tool that would come with any PostgreSQL
> installation would please them.  Some sort of psqlGUI, I guess.

Why reinvent the wheel? I would say that putting the development
effort into the OpenOffice Base app would be time better spent.

Geoff


Re: Thoughts on "Love Your Database"

From
Achilleas Mantzios
Date:
On 17/05/2016 12:16, Geoff Winkless wrote:
> On 17 May 2016 at 09:34, Pierre Chevalier Géologue
> <pierrechevaliergeol@free.fr> wrote:
>> On this matter, I hear *very* often from such guys that the only reproach
>> they have to PostgreSQL is that it does not come with a slick GUI like
>> Access.  PGAdmin does not suit their needs at all: they want to design their
>> forms, directly write into the tables by using quick'n easy/dirty copy/paste
>> from/to their Excel (yes, it is still lying around).  I understand them,
>> somehow.
>> There are a few tools around, many proprietary ones, some Free/Libre ones,
>> but they are still looking for a sort of Holy Grail that would definitely
>> convince them.  A standard client tool that would come with any PostgreSQL
>> installation would please them.  Some sort of psqlGUI, I guess.
> Why reinvent the wheel? I would say that putting the development
> effort into the OpenOffice Base app would be time better spent.
Sorry if I missed something but what's wrong with pgadmin3 ?
> Geoff
>
>


--
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt



Re: Thoughts on "Love Your Database"

From
Geoff Winkless
Date:
On 17 May 2016 at 10:22, Achilleas Mantzios
<achill@matrix.gatewaynet.com> wrote:
> On 17/05/2016 12:16, Geoff Winkless wrote:
>>
>> On 17 May 2016 at 09:34, Pierre Chevalier Géologue
>> <pierrechevaliergeol@free.fr> wrote:
>>>
>>> On this matter, I hear *very* often from such guys that the only reproach
>>> they have to PostgreSQL is that it does not come with a slick GUI like
>>> Access.  PGAdmin does not suit their needs at all: they want to design
>>> their
>>> forms, directly write into the tables by using quick'n easy/dirty
>>> copy/paste
>>> from/to their Excel (yes, it is still lying around).  I understand them,
>>> somehow.
>>> There are a few tools around, many proprietary ones, some Free/Libre
>>> ones,
>>> but they are still looking for a sort of Holy Grail that would definitely
>>> convince them.  A standard client tool that would come with any
>>> PostgreSQL
>>> installation would please them.  Some sort of psqlGUI, I guess.
>>
>> Why reinvent the wheel? I would say that putting the development
>> effort into the OpenOffice Base app would be time better spent.
>
> Sorry if I missed something but what's wrong with pgadmin3 ?

There's nothing wrong with pgadmin as such.

From the very email you just quoted:

>>> they want to design their forms

ie (as I understand it) they're after some sort of RAD tool.

Geoff


Re: Thoughts on "Love Your Database"

From
Guyren Howe
Date:
On May 17, 2016, at 2:22 , Achilleas Mantzios <achill@matrix.gatewaynet.com> wrote:
>
> Sorry if I missed something but what's wrong with pgadmin3 ?

Apart from it's awful, clunky, bug-ridden and crash prone, nothing.



Re: Thoughts on "Love Your Database"

From
Raymond O'Donnell
Date:
On 17/05/2016 18:38, Guyren Howe wrote:
> On May 17, 2016, at 2:22 , Achilleas Mantzios <achill@matrix.gatewaynet.com> wrote:
>>
>> Sorry if I missed something but what's wrong with pgadmin3 ?
>
> Apart from it's awful, clunky, bug-ridden and crash prone, nothing.

In fairness to pgAdmin 3:

- It's not a development platform, such as MS Access tries to be; it's
an admin tool, pure and simple.

- pgAdmin 4 is in heavy development, and not too far from a beta;
pgAdmin 3 has only been receiving bug fixes for quite some time now.

- A lot of the problems in pgAdmin 3 are due to upstream bugs in
wxWidgets, over which the pgAdmin team has no control (hence pgAdmin 4).

Having said all that, I've rarely had any trouble with pgAdmin 3 on
Windows 7 and XP, Ubuntu and Debian; just a very occasional crash (maybe
one every six months).

Ray.
--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie


Re: Thoughts on "Love Your Database"

From
Achilleas Mantzios
Date:
On 17/05/2016 20:38, Guyren Howe wrote:
> On May 17, 2016, at 2:22 , Achilleas Mantzios <achill@matrix.gatewaynet.com> wrote:
>> Sorry if I missed something but what's wrong with pgadmin3 ?
> Apart from it's awful, clunky, bug-ridden and crash prone, nothing.
>
There is a solution for that : either find the bugs and submit patches or pay the developers to fix the bugs or make
youa custom version 
or go buy some other tool, or write your own or live with psql (like most people do).
In the occasions (once/twice a week) that I needed pgadmin during my last 16 years with postgresql, it delivered just
fine.
Some guys here use some better tools to access pgsql but they all cost money. I have paid for RazorSQL for accessing
ourMS SQL server, 
then felt lucky I was accessing pgsql via psql (or even pgqdmin3) all those years.

--
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt



Re: Thoughts on "Love Your Database"

From
Adam Brusselback
Date:
> On Tue, May 17, 2016 at 1:54 PM, Raymond O'Donnell <rod@iol.ie> wrote:
> Having said all that, I've rarely had any trouble with pgAdmin 3 on
> Windows 7 and XP, Ubuntu and Debian; just a very occasional crash (maybe
> one every six months).

So just to chime in, it has not been at all that stable for my team and I.  It's not bad when connections are all stable or you're connecting to a local instance, but if the connection between you and the server isn't perfect... it's one of the least stable pieces of software I've ever used.

I'm sure for those who's servers are hosted locally, and you connect through a lan, or those with a decent provider, it works much better than for me.
My team is all remote though, and we don't have an office. Each of my employees connects using their own internet connection, with varying reliability.  Servers hosted on a cloud provider.  Crashes happen multiple times a day for most.

Just wanted to share my experience.

Re: Thoughts on "Love Your Database"

From
"David G. Johnston"
Date:
On Wednesday, May 18, 2016, Adam Brusselback <adambrusselback@gmail.com> wrote:
> On Tue, May 17, 2016 at 1:54 PM, Raymond O'Donnell <rod@iol.ie> wrote:
> Having said all that, I've rarely had any trouble with pgAdmin 3 on
> Windows 7 and XP, Ubuntu and Debian; just a very occasional crash (maybe
> one every six months).

So just to chime in, it has not been at all that stable for my team and I.  It's not bad when connections are all stable or you're connecting to a local instance, but if the connection between you and the server isn't perfect... it's one of the least stable pieces of software I've ever used.

I'm sure for those who's servers are hosted locally, and you connect through a lan, or those with a decent provider, it works much better than for me.
My team is all remote though, and we don't have an office. Each of my employees connects using their own internet connection, with varying reliability.  Servers hosted on a cloud provider.  Crashes happen multiple times a day for most.


Have you tried interjecting pg_bouncer into the flow?  Probably on the client machine.

David J. 

Re: Thoughts on "Love Your Database"

From
Pierre Chevalier Géologue
Date:
Hi,

Le 17/05/2016 10:44, John R Pierce a écrit :
> On 5/17/2016 1:34 AM, Pierre Chevalier Géologue wrote:
>>
>> On this matter, I hear *very* often from such guys that the only
>> reproach they have to PostgreSQL is that it does not come with a slick
>> GUI like Access.
>
> Access is a lot more than a slick GUI,

Yes; some claim that it is even a database.  I was just trying to mean
that the GUI part of Access (to design forms, work with data almost like
in a spreadsheet) was what these fellows were missing.


> its a rapid application development system based on VisualBasic.

Well, I wouldn't say exactly so.  VB was incorporated a while after the
release of VB... 2, was it?  I can't remember well.
Sure, you can put VB code in your Access .mdb (or .mda), but you can
certainly design a whole GUI for your database without the need of any
VB line of code.

À+
Pierre
--
____________________________________________________________________________
Pierre Chevalier
PChGEI: Pierre Chevalier Géologue Et Informaticien
Partenaire DALIBO
     Mesté Duran
     32100 Condom
   Tél+fax  :    09 75 27 45 62
                 06 37 80 33 64
   Émail  :   pierrechevaliergeolCHEZfree.fr
   icq#   :   10432285
   jabber: pierre.chevalier1967@jabber.fr
   http://pierremariechevalier.free.fr/pierre_chevalier_geologue
____________________________________________________________________________


Re: Thoughts on "Love Your Database"

From
Pierre Chevalier Géologue
Date:
Le 17/05/2016 11:25, Geoff Winkless a écrit :
>>>> but they are still looking for a sort of Holy Grail that would definitely
>>>> convince them.  A standard client tool that would come with any
>>>> PostgreSQL
>>>> installation would please them.  Some sort of psqlGUI, I guess.
>>>
>>> Why reinvent the wheel? I would say that putting the development
>>> effort into the OpenOffice Base app would be time better spent.

True.  But I must say that I would be looking towards something a bit
lighter.  LibreOffice is a bit of a heavyweight, IMHO.  The "Base" is
kind of bizarre to use, I always miss some of its logic, somehow.  I
have to try its latest version, see if it's decently usable for a lambda
user.


>> Sorry if I missed something but what's wrong with pgadmin3 ?
> There's nothing wrong with pgadmin as such.

Yes, nothing wrong at all.  It is not meant to make UI.  Just some basic
features are implemented for table data editing.


>  From the very email you just quoted:
>>>> they want to design their forms
> ie (as I understand it) they're after some sort of RAD tool.

Yes, that's it, in a way.  Although designing forms is not what I would
call AD (application development)...
When you look back at dBase III or IV, the text user interface which
allowed to interact with the data was very simple, and efficient.
Designing forms (I didn't do much of these, and I can't remember well)
was quite straightforward, and was not at all what I would call an
"application development".  The latter would be made by using clipper,
most often.

À+
Pierre
--
____________________________________________________________________________
Pierre Chevalier
PChGEI: Pierre Chevalier Géologue Et Informaticien
Partenaire DALIBO
     Mesté Duran
     32100 Condom
   Tél+fax  :    09 75 27 45 62
                 06 37 80 33 64
   Émail  :   pierrechevaliergeolCHEZfree.fr
   icq#   :   10432285
   jabber: pierre.chevalier1967@jabber.fr
   http://pierremariechevalier.free.fr/pierre_chevalier_geologue
____________________________________________________________________________


Re: Thoughts on "Love Your Database"

From
Pierre Chevalier Géologue
Date:
Interesting point of view.  Time to make a bug report, isn't it?  ;-)

À+
Pierre


Le 18/05/2016 17:44, Adam Brusselback a écrit :
>> On Tue, May 17, 2016 at 1:54 PM, Raymond O'Donnell<rod@iol.ie <mailto:rod@iol.ie>> wrote:
>
>> Having said all that, I've rarely had any trouble with pgAdmin 3 on
>
>> Windows 7 and XP, Ubuntu and Debian; just a very occasional crash (maybe
>
>> one every six months).
>
> So just to chime in, it has not been at all that stable for my team and
> I.  It's not bad when connections are all stable or you're connecting to
> a local instance, but if the connection between you and the server isn't
> perfect... it's one of the least stable pieces of software I've ever used.
>
> I'm sure for those who's servers are hosted locally, and you connect
> through a lan, or those with a decent provider, it works much better
> than for me.
> My team is all remote though, and we don't have an office. Each of my
> employees connects using their own internet connection, with varying
> reliability.  Servers hosted on a cloud provider.  Crashes happen
> multiple times a day for most.
>
> Just wanted to share my experience.

--
____________________________________________________________________________
Pierre Chevalier
PChGEI: Pierre Chevalier Géologue Et Informaticien
Partenaire DALIBO
     Mesté Duran
     32100 Condom
   Tél+fax  :    09 75 27 45 62
                 06 37 80 33 64
   Émail  :   pierrechevaliergeolCHEZfree.fr
   icq#   :   10432285
   jabber: pierre.chevalier1967@jabber.fr
   http://pierremariechevalier.free.fr/pierre_chevalier_geologue
____________________________________________________________________________


Re: Thoughts on "Love Your Database"

From
John R Pierce
Date:
On 5/18/2016 11:05 AM, Pierre Chevalier Géologue wrote:

Yes, that's it, in a way.  Although designing forms is not what I would call AD (application development)...
When you look back at dBase III or IV, the text user interface which allowed to interact with the data was very simple, and efficient. Designing forms (I didn't do much of these, and I can't remember well) was quite straightforward, and was not at all what I would call an "application development".  The latter would be made by using clipper, most often.


MS Access is all about forms, reports, and data, with visualbasic macros for data manipulation.



-- 
john r pierce, recycling bits in santa cruz

Re: Thoughts on "Love Your Database"

From
Pierre Chevalier Géologue
Date:
Le 04/05/2016 18:29, Szymon Lipiński a écrit :
> On the other hand, when I was trying to store all my logic in a
> database, there was just one thing that made me hate it. Testing.
> Testing the procedures inside the database was not easy, not funny, and
> too much time consuming.

Yes, very good point.

À+
Pierre
--
____________________________________________________________________________
Pierre Chevalier
PChGEI: Pierre Chevalier Géologue Et Informaticien
Partenaire DALIBO
     Mesté Duran
     32100 Condom
   Tél+fax  :    09 75 27 45 62
                 06 37 80 33 64
   Émail  :   pierrechevaliergeolCHEZfree.fr
   icq#   :   10432285
   jabber: pierre.chevalier1967@jabber.fr
   http://pierremariechevalier.free.fr/pierre_chevalier_geologue
____________________________________________________________________________


Re: Thoughts on "Love Your Database"

From
Guyren Howe
Date:
On May 20, 2016, at 13:38 , Pierre Chevalier Géologue <pierrechevaliergeol@free.fr> wrote:
>
> Le 04/05/2016 18:29, Szymon Lipiński a écrit :
>> On the other hand, when I was trying to store all my logic in a
>> database, there was just one thing that made me hate it. Testing.
>> Testing the procedures inside the database was not easy, not funny, and
>> too much time consuming.
>
> Yes, very good point.

Are there any best practices or tricks to make this easier?

Re: Thoughts on "Love Your Database"

From
Pierre Chevalier Géologue
Date:
Interesting conversation.

While reading it, I sort of regret the times when a single guy was in
charge of the whole thing, and managed to simply make it work, using all
possible tools he had.  "Informaticien" was the generic term, in French.

Every single part of the big thing he built (hardware on server and
clients' sides, database, network, client programs, server programs,
etc.) may not be perfect (often from far), but the whole thing was
running smoothly, and he knew perfectly what to fix when something was
happening.
Yes, it took a multipurpose fellow to do that, neither a "SQL-only"
fellow, nor a "C-what-else" guy.


It also reminds me of a paper I read once, where it was carefully
explained why scientists hated databases.  But that's another subject.


Le 04/05/2016 21:22, Will McCormick a écrit :
> Yeah but your already paying for a developer ...

À+
Pierre
--
____________________________________________________________________________
Pierre Chevalier
PChGEI: Pierre Chevalier Géologue Et Informaticien
Partenaire DALIBO
     Mesté Duran
     32100 Condom
   Tél+fax  :    09 75 27 45 62
                 06 37 80 33 64
   Émail  :   pierrechevaliergeolCHEZfree.fr
   icq#   :   10432285
   jabber: pierre.chevalier1967@jabber.fr
   http://pierremariechevalier.free.fr/pierre_chevalier_geologue
____________________________________________________________________________


Re: Thoughts on "Love Your Database"

From
Steve Atkins
Date:
> On May 20, 2016, at 1:43 PM, Guyren Howe <guyren@gmail.com> wrote:
>
> On May 20, 2016, at 13:38 , Pierre Chevalier Géologue <pierrechevaliergeol@free.fr> wrote:
>>
>> Le 04/05/2016 18:29, Szymon Lipiński a écrit :
>>> On the other hand, when I was trying to store all my logic in a
>>> database, there was just one thing that made me hate it. Testing.
>>> Testing the procedures inside the database was not easy, not funny, and
>>> too much time consuming.
>>
>> Yes, very good point.
>
> Are there any best practices or tricks to make this easier?

In-database unit tests help. pgTap is a decent framework
for building that sort of test-suite in a way that'll play nice with
reporting and CI tools.

http://pgtap.org

Cheers,
  Steve



Re: Thoughts on "Love Your Database"

From
Szymon Lipiński
Date:


On 21 May 2016 at 00:08, Steve Atkins <steve@blighty.com> wrote:

> On May 20, 2016, at 1:43 PM, Guyren Howe <guyren@gmail.com> wrote:
>
> On May 20, 2016, at 13:38 , Pierre Chevalier Géologue <pierrechevaliergeol@free.fr> wrote:
>>
>> Le 04/05/2016 18:29, Szymon Lipiński a écrit :
>>> On the other hand, when I was trying to store all my logic in a
>>> database, there was just one thing that made me hate it. Testing.
>>> Testing the procedures inside the database was not easy, not funny, and
>>> too much time consuming.
>>
>> Yes, very good point.
>
> Are there any best practices or tricks to make this easier?

In-database unit tests help. pgTap is a decent framework
for building that sort of test-suite in a way that'll play nice with
reporting and CI tools.

http://pgtap.org

Cheers,
  Steve


Yea, pgtap is an interesting solution which I used. Or tried to use. Using it was quite painful, and I gave up. Now I test the database things outside the database. Maybe there is something wrong with me, but for me it looks like me and pgtap really don't like each other.

But of course all people should check on their own. 


--
    regards Szymon Lipiński

Re: Thoughts on "Love Your Database"

From
Szymon Lipiński
Date:


On 20 May 2016 at 22:43, Guyren Howe <guyren@gmail.com> wrote:
On May 20, 2016, at 13:38 , Pierre Chevalier Géologue <pierrechevaliergeol@free.fr> wrote:
>
> Le 04/05/2016 18:29, Szymon Lipiński a écrit :
>> On the other hand, when I was trying to store all my logic in a
>> database, there was just one thing that made me hate it. Testing.
>> Testing the procedures inside the database was not easy, not funny, and
>> too much time consuming.
>
> Yes, very good point.

Are there any best practices or tricks to make this easier?


I only write tests outside the database. Currently I'm involved in projects where all the logic is outside, so having tests outside is rather obvious. However I have a small toy project with logic inside the database, and tests outside. I also think that it doesn't matter where the tests are, it is important to have them, and run them. I'm not sure that tests inside are much better solution.


--
    regards Szymon Lipiński

Re: Thoughts on "Love Your Database"

From
Chris Travers
Date:


On Fri, May 20, 2016 at 10:43 PM, Guyren Howe <guyren@gmail.com> wrote:
On May 20, 2016, at 13:38 , Pierre Chevalier Géologue <pierrechevaliergeol@free.fr> wrote:
>
> Le 04/05/2016 18:29, Szymon Lipiński a écrit :
>> On the other hand, when I was trying to store all my logic in a
>> database, there was just one thing that made me hate it. Testing.
>> Testing the procedures inside the database was not easy, not funny, and
>> too much time consuming.
>
> Yes, very good point.

Are there any best practices or tricks to make this easier?

Strangely I have never had a problem testing stored procedures.  You have to create a data set for the tests of course and that is the hardest part, but there are some really nice things:

1.  If your test scripts always roll back you can run them on a production database as a troubleshooting step
2.  It is easy to hook things up to a TAP harness (whether using PgTAP or some hand-rolled solution).  I think it would be harder to connect to xunit though.  So use TAP ;-)
3.  I usually create a test results table (in my test case, rolled back after!) which stores the test description and pass status.  That makes it easy to check using other tools.

Usually I set aside a range of things (negative id's for example) for testing purposes.
 

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



--
Best Wishes,
Chris Travers

Efficito:  Hosted Accounting and ERP.  Robust and Flexible.  No vendor lock-in.

Re: Thoughts on "Love Your Database"

From
Szymon Lipiński
Date:


On 21 May 2016 at 11:28, Chris Travers <chris.travers@gmail.com> wrote:


On Fri, May 20, 2016 at 10:43 PM, Guyren Howe <guyren@gmail.com> wrote:
On May 20, 2016, at 13:38 , Pierre Chevalier Géologue <pierrechevaliergeol@free.fr> wrote:
>
> Le 04/05/2016 18:29, Szymon Lipiński a écrit :
>> On the other hand, when I was trying to store all my logic in a
>> database, there was just one thing that made me hate it. Testing.
>> Testing the procedures inside the database was not easy, not funny, and
>> too much time consuming.
>
> Yes, very good point.

Are there any best practices or tricks to make this easier?

Strangely I have never had a problem testing stored procedures.  You have to create a data set for the tests of course and that is the hardest part, but there are some really nice things:

1.  If your test scripts always roll back you can run them on a production database as a troubleshooting step
2.  It is easy to hook things up to a TAP harness (whether using PgTAP or some hand-rolled solution).  I think it would be harder to connect to xunit though.  So use TAP ;-)
3.  I usually create a test results table (in my test case, rolled back after!) which stores the test description and pass status.  That makes it easy to check using other tools.

Usually I set aside a range of things (negative id's for example) for testing purposes.


I had problems, and I'm really interested in making it work for me. I have a couple of questions:
How do you manage versioning of the stored procedures? Especially do you have any problems upgrades?
What about testing logic which is outside the database? Do you use pgtap for testing the schema only, or to test some of the external logic as well?
Do you use logic inside and outside the database at the same time?
How does this scale to a couple of servers when the load is so huge you need to have e.g. ten physical web servers at front? It seems for me that it would be easier to spread the cpu logic overhead to plenty of servers instead of having just one machine which needs to do all the things. But maybe I'm wrong.


--
    regards Szymon Lipiński

Re: Thoughts on "Love Your Database"

From
Chris Travers
Date:


On Sat, May 21, 2016 at 12:49 PM, Szymon Lipiński <mabewlun@gmail.com> wrote:


Strangely I have never had a problem testing stored procedures.  You have to create a data set for the tests of course and that is the hardest part, but there are some really nice things:

1.  If your test scripts always roll back you can run them on a production database as a troubleshooting step
2.  It is easy to hook things up to a TAP harness (whether using PgTAP or some hand-rolled solution).  I think it would be harder to connect to xunit though.  So use TAP ;-)
3.  I usually create a test results table (in my test case, rolled back after!) which stores the test description and pass status.  That makes it easy to check using other tools.

Usually I set aside a range of things (negative id's for example) for testing purposes.


I had problems, and I'm really interested in making it work for me. I have a couple of questions:
How do you manage versioning of the stored procedures? Especially do you have any problems upgrades?

We reload all stored procedures on every upgrade.  I have seen a lot of projects that do this when the stored procedures are heavy.   Versioning then happens via another program (git mercurial, svn...)

transactional ddl makes this pretty seemless.
 
What about testing logic which is outside the database? Do you use pgtap for testing the schema only, or to test some of the external logic as well?

I actually use a TAP harness with a home-brewed interface for attaching to the stored procedures.  I threw it together in a couple of hours (the translation layer is in Perl).  It isn't perfect but it works generally.  We could use pgTAP and avoid the translation layer but didn't want to add it as a build/test dependency there.  We are considering using pgTAP for schema tests that are not intended to be run on other systems.
 
Do you use logic inside and outside the database at the same time?

Most of the projects I have worked on that have done stored proc testing have been Perl projects and the typical approach there is to use a TAP harness for testing.  The stored procedures are in their own test script.  We have other tests (including integration tests) in other test scripts.  For LedgerSMB our db tests can be run against a live production db as can some of our integration tests, but others (those that rely on actual http queries) cannot be.

But these are all integrated in the test framework so when you do:

make test

your environment variables determine what is tested (and it may include database logic).

I don't know how it would work with xunit but the same basic approach we use could be used elssewhere.

basically, our test adaptor basically runs scripts, each of which:

1.  Loads test adata and creates a schema for storing test results
2.  Run tests, storing the results in the test_results table
3.  Output a report of test results
4.  Rolls back

That output is then parsed, and converted into test output for our test framework.
 
How does this scale to a couple of servers when the load is so huge you need to have e.g. ten physical web servers at front?

If you are asking about scalability testing and load testing, you aren't going to use the same approaches you do for unit tests.  When I have had to do these, I have typically had to write tools to run, for example, a stored procedure with different arguments many times in parallel.  Obviously you don't do this on a production system under load.

For other environments I have never seen one that didn't have staging and testing environments and that;s where you would look initially at some of these.

Now this being said, load affects database query performance in ways that aren't always as one would expect (for example, what is in cache can affect things quite a lot).
 
It seems for me that it would be easier to spread the cpu logic overhead to plenty of servers instead of having just one machine which needs to do all the things. But maybe I'm wrong.

But that is a different question.  If you are dealing with large databases under load (say, for example, an 11TB database which serves a web front-end plus an HPC cluser of many nodes, totalling, say, a commitment to handle up to say 500 cpu cores as client apps running 24/7), performance in your database is something which you will have to pay very close attention to.  Some things you will want to handle outside the database, to be sure.   Some other things you will want to make sure the logic is well contained in the database.

You can't always say pulling the data to the client and processing it there always improves scalability.  Concerns such as effective use of the buffer cache can make it very important to get the logic in the right place.  Additionally some things in PostgreSQL, like deTOASTing data can add a lot of overhead that you might be able to avoid with the right functions.  If you need solid scalability you need people who understand performance costs of various options and can weigh them in a particular context.
 


--
    regards Szymon Lipiński



--
Best Wishes,
Chris Travers

Efficito:  Hosted Accounting and ERP.  Robust and Flexible.  No vendor lock-in.