News for hackers. Stuff that matters.
Re:SQL is 43 years old – Here’s why we still use it today by scarface74 on Tuesday May 02, 2017 @08:44AM (#14245881)
Does your code expect property "X" to be on a "Player" object? Do you put a check everywhere for when it doesn't? Do you have default value for objects that were created before new property was added

Why would you put checks everywhere a properly written code base would have one module/service that handles the player object and every consumer would use that one module.

Re:SQL is 43 years old – Here’s why we still use it today by aidos on Tuesday May 02, 2017 @09:03AM (#14245982)
There have to be some checks, somewhere. Even though it's limited to one module, you can get temporal inconsistencies.

e.g. you add a new field and an application level default, then later that default is changed. Now there's no notion of which default the docs that never had the property should be using. Sure, you just need to patch the old docs to set the property where it's missing. But the GPs point was that by not keeping a consistent schema you end up moving the definition of the data into the application, and you need to be very aware of the trade-off.

Personally I'm really happy using postgres and dropping into jsonb when it's the correct model to use. It's the best of both worlds as far as I'm concerned. I've built and worked on systems using nosql solutions that have been migrated back to sql and the data inconsistencies we found have made me very wary of having a primary datastore that doesn't enforce strict constraints.

Though, everybody's use case is different.

Re:SQL is 43 years old – Here’s why we still use it today by scarface74 on Tuesday May 02, 2017 @09:19AM (#14246081)
But the GPs point was that by not keeping a consistent schema you end up moving the definition of the data into the application, and you need to be very aware of the trade-off.

Why wouldn't the defaults be in the application? Why wouldn't it be treated like any other piece of business logic in code that should be unit tested?

That being said, I only caught the NoSQL religion about six months ago when I started using Mongo. But SQL Server 2016 has such great support for JSON natively, as long as I'm spending other people's money, I prefer having the best of both worlds.

Re:SQL is 43 years old – Here’s why we still use it today by elmigranto on Tuesday May 02, 2017 @10:00AM (#14246351)
> Why wouldn't the defaults be in the application? Why wouldn't it be treated like any other piece of business logic in code that should be unit tested?

How about we check our data in the place where it lives given how very robust and mature products that do that were already written, tested, and used in production by literally thousands of people for decades.

Re:SQL is 43 years old – Here’s why we still use it today by scarface74 on Tuesday May 02, 2017 @01:31PM (#14248497)
How about we check our data in the place where it lives given how very robust and mature products that do that were already written, tested, and used in production by literally thousands of people for decades.

So by "checking data" can we check all of the business constraints?

Re:SQL is 43 years old – Here’s why we still use it today by elmigranto on Tuesday May 02, 2017 @01:46PM (#14248675)
Yes. If you really want to.

Definetly stuff like presence of fields and their basic sanity (string not being empty or within a certain length), date intervals, uniqueness of certain fields or combinations, etc.

You can go as far as you want, really; but like with most cases, when there's a range of possibilities, both extremes are probably a wrong answer.