Skip to main content

Posts tagged with 'SQL'

My job as a developer evangelist for Couchbase means than I work much less with SQL Server than I used to. However, it doesn't mean I don't keep up with it.

In fact, inspired by Couchbase, I decided to try out using SQL Server as a sort of document data store. SQL Server 2016 introduced some interesting new features that make this kinda possible: JSON_VALUEJSON_QUERY, and JSON_MODIFY.

I set up a "document" table, which is two fields: a guid and an nvarchar(max). This is kinda like a Couchbase bucket: a key and a JSON document to go with it.

I put fairly complex hierarchical documents in these fields, something like:

I say "fairly complex", because representing this in a standard normalized fashion would require at least two tables, foreign keys, constraints, and then data migration and schema migration as the model evolves.

Now, suppose I want to execute a query and find all the document that are "Show=true". With Couchbase and N1QL, I would just use something like "SELECT * FROM `bucket` WHERE show = true".

With SQL Server, there's a little more work. "SELECT t.key, t.doc FROM [table] t WHERE JSON_VALUE(t.SpeakingInfo,'$.Show') = 'true'". Notice that JSON_VALUE is being applied to a text field, and a JSON path is used within JSON_VALUE to get a specific value from within that JSON object.

For this simple project I'm doing, that's all I need. No idea yet what kind of performance level I can expect from JSON_VALUE and more complex JSON paths.

But, this is definitely an example of the kinds of database convergence I've been telling people about. The separations between NoSQL and SQL are becoming less strict, at least in terms of data modeling and querying.

You need to be using SQL Server 2016 or SQL Server Azure to take advantage of the JSON_* functions.

Latish Sehgal is boostrapping his side project.

Show Notes:

Latish Sehgal is on Twitter

Want to be on the next episode? You can! All you need is the willingness to talk about something technical.

Theme music is "Crosscutting Concerns" by The Dirty Truckers, check out their music on Amazon or iTunes.

I was recently on David Giard's show Technology and Friends! This is my second time on his show. This time I got to talk about NoSQL and Couchbase Server in particular. Check it out, and check out Couchbase Server.

 

I've just wrapped up my first week at Couchbase. So far, I like the job quite a bit.

One of the things I've been tasked with is to brainstorm a plan of things that Couchbase can do to reach out to developers, but specifically to Microsoft-oriented developers.

Couchbase love Microsoft

I've already talked to some of you for ideas, and I've created a huge list. The next step will be to pare down the list, prioritize it, and start working on it. But before I do that, let me send out one more appeal to developers of all kinds, including MS developers: what can I do to better communicate with and help you and your peers? Be as specific or general as you'd like!

Feel free to leave a comment below, hit me on Twitter via @mgroves, use my Contact Form, or email me directly matthew.groves AT couchbase DOT com

Welcome to another "Weekly Concerns". This is a post-a-week series of interesting links, relevant to programming and programmers. You can check out previous Weekly Concerns posts in the archive.

If you have an interesting link that you'd like to see in Weekly Concerns, leave a comment or contact me.

Matthew D. Groves

About the Author

Matthew D. Groves lives in Central Ohio. He works remotely, loves to code, and is a Microsoft MVP.

Latest Comments

Twitter