RELATIONAL to Nosql: GETTING STARTED from SQL SERVER
Total Page:16
File Type:pdf, Size:1020Kb
RELATIONAL RELATIONALTO NoSQL: TO NoSQL: GETTING STARTED FROM SQL SERVER Getting Started From SQL Server RELATIONAL TO NoSQL: GETTING STARTED FROM SQL SERVER Why the shift to NoSQL? Customer loyalty and The business world is undergoing massive change as industry after industry shifts competitive advantage to the digital economy. It’s an economy powered by the internet and other 21st hinges on customer century technologies – the cloud, mobile, social media, and big data. At the heart experiences. of every digital economy business are its web, mobile, and Internet of Things (IoT) applications: They’re the primary way companies interact with customers Customers demand today, and how companies run more and more of their business. The experiences responsive, intelligent, and that companies deliver via those apps largely determine how satisfied – and how immersive apps. Building a great-looking app is just loyal – customers will be. the beginning. How are these applications different from legacy enterprise applications like ERP, HR, and financial accounting? Fundamentally, they are about customer interactions rather than transactions. As customers spend more and more time interacting than transacting, every interaction counts. They expect exceptional experiences every time, regardless of the device, location, or time. Customers demand responsive, intelligent, and immersive apps. Building a great-looking app is just the beginning. Liberating data fast, and at scale, makes all the difference. It’s where other legacy database technologies fall short. Today’s web, mobile, and IoT applications share one or more (if not all) of the following characteristics. They need to: • Focus on the overall customer, employee, and customer experience, not just capturing the transaction • Support large numbers of concurrent users (tens of thousands, perhaps millions) • Deliver highly responsive experiences to a globally distributed base of users • Be always available – no downtime • Handle semi- and unstructured data • Rapidly adapt to changing requirements with frequent updates and new features Building and running these web, mobile, and IoT applications has created a new set of technology requirements. The new enterprise technology architecture needs to be far more agile than ever before, and requires an approach to real-time data management that can accommodate unprecedented levels of scale, speed, and data variability. Relational databases are unable to meet these new requirements, and enterprises are therefore turning to NoSQL database technology. Consider just a few examples of Global 2000 enterprises that are deploying NoSQL for mission-critical applications that have been discussed in recent news reports: The shift from • Tesco, Europe’s #1 retailer, deploys NoSQL for eCommerce, product catalog, transactions to and other applications interactions requires a different kind of • Ryanair, the world’s busiest airline, uses NoSQL to power its mobile app database. serving over 3 million users Couchbase’s NoSQL Data Platform enables • Marriott deployed NoSQL to modernize its reservation system that books enterprises to deploy $38 billion annually solutions that provide more agility, better • Gannett, the #1 U.S. newspaper publisher, replaced SQL Server with NoSQL performance, and easier administration to power its digital publishing platform, Presto at lower cost. • GE is deploying NoSQL for its Predix platform to help manage the Industrial Internet • Cars.com, with over 30 million visits per month, replaced SQL Server with NoSQL to store customer and vehicle data At Couchbase, we’ve enabled hundreds of enterprises, as well as numerous growth companies and startups, to deploy NoSQL for better agility, performance, simpler maintenance, and lower costs. The goal of this paper is to help you introduce NoSQL into your infrastructure by highlighting lessons learned from enterprises that successfully adopted NoSQL. We’ll explore key considerations and strategies for transitioning to NoSQL, in particular, to a document database (Couchbase Server), with tips for moving from SQL Server and other relational databases. Note, there are use cases in which Couchbase can be used to replace existing infrastructure, as well as use cases where Couchbase can be used to complement existing relational technology by adding performance, agility, and polyglot persistence. We’ll start with recommendations for identifying and selecting the right application. Next, we’ll cover strategies for modeling relational data as documents, how to access them within your application, and how to migrate data from a relational database. Finally, we’ll highlight the basics of operating a NoSQL database in comparison to a relational database. Top 5 reasons companies replace SQL Server with a NoSQL database If you’re running into limits with Microsoft SQL Server (or other relational databases) – either in terms of rising costs and complexity, or in scaling to meet your requirements – this is the time to evaluate a NoSQL database. Many companies have chosen Couchbase Server either to augment Microsoft SQL Server and other relational databases, or in some cases replace them. Their top 5 reasons: Easier to scale Whether running on 3 nodes or hundreds – in 1 data center or many – Couchbase Server is based on a distributed architecture to scale on commodity hardware with ease, regardless of the operating system. 3 Better performance Couchbase Server features an integrated cache, memory-optimized indexes, and memory-to-memory replication to deliver consistent, high throughput with submillisecond response time, at any scale. Many enterprises have Up to 40x lower cost successfully introduced With subscriptions based on the number of instances, Couchbase Server typically NoSQL by identifying costs 5-40x less than SQL Server and its per-core based licensing – especially on a single application or servers with many cores. service to start with. Cross-platform Couchbase Server can be deployed on Windows or Linux (Red Hat, Ubuntu, Debian, and more), simplifying deployment and administration by decoupling the database from the operating system. Greater agility With a JSON-based data model and a SQL-based query language, Couchbase Server enables developers to build applications easier, faster, and without the need for complex object/relational mapping. Identifying the right application Many enterprises have successfully introduced NoSQL by identifying a single application or service to start with. It could be a new one that is being developed, or an existing application that’s being refactored. Examples include: • A high performance, highly available caching service • A small, independent application with a narrow scope • A logical or physical service within a large application • A global service that powers multiple applications Ideal candidates have one or more of the following characteristics or requirements: • Fast iteration – the data model needs to be modified continuously or on demand (e.g., to accommodate new preferences, new social media accounts, etc.). • Read and write JSON documents (semi-structured data) to/from web and mobile clients. • Provide low latency, high throughput access to data — e.g., users expect interactions to be instant, and waiting negatively impacts the experience (e.g., users abandon shopping carts) • Support thousands to millions of concurrent users — e.g., the number of users is increasing, sometimes exponentially, as when content goes viral • Users are not limited to a specific country or region — they’re everywhere • Users are not limited to specific hours — the service has to be available 24x7 • Store terabytes of data • Deploy in multiple data centers with an active/active configuration 4 Some common examples of good fits for NoSQL: • Product Catalog Service • Asset Tracking Service • Content Management Service • Application Configuration Service • Customer Management Service Couchbase Server is a • File or Streaming Metadata Service document database — data is stored in • Mobile Field Enablement Services JSON documents, not in tables. • Consumer-centric Mobile Services Every JSON document includes its own flexible Modeling and migrating your data schema, and it can be changed on demand Couchbase Server is a document database – data is stored in JSON documents, by changing the not in tables. While relational databases rely on an explicit predefined schema to document itself. describe the structure of data, document databases do not – JSON documents are self-describing. As such, every JSON document includes its own flexible schema, and it can be changed on demand by changing the document itself. Figure 1: Relational schema and data vs. self-describing JSON documents It’s important to understand that JSON documents are not limited to fields. They can include arrays and objects, and they can be nested, just like applications. For this reason, there is no “impedance mismatch” between application objects and JSON documents. Figure 2: Multiple tables vs. nested data with JSON documents 5 Just as every row in a table requires a primary key, every document requires an Object ID. Many applications rely on relational databases to automatically generate the primary key (for example, with the IDENTITY columns in Microsoft SQL Server). However, with document databases, applications should leverage natural keys where possible. In a relational database, primary keys are defined per table. It’s not uncommon NOTE: for the primary key of different rows in different tables to have