{"id":10223,"date":"2025-08-04T08:56:24","date_gmt":"2025-08-04T15:56:24","guid":{"rendered":"https:\/\/www.couchbase.com\/developers\/tutorials\/schemaless-data-modeling\/"},"modified":"2025-08-04T08:56:24","modified_gmt":"2025-08-04T15:56:24","slug":"schemaless-data-modeling","status":"publish","type":"tutorials","link":"https:\/\/www.couchbase.com\/it\/developers\/tutorials\/schemaless-data-modeling\/","title":{"rendered":"Schemaless Data Modeling"},"content":{"rendered":"<p class=\"wp-block-paragraph\">When you use documents to represent data, a database schema is optional. The majority of your effort will be creating one or more documents that will represent application data. This document structure can evolve over time as your application grows and adds new features.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In Couchbase Server you do not need to perform data modeling and establish relationships between tables the way you would in a traditional relational database. Technically, every document you store with structure in Couchbase Server has its own implicit schema; the schema is represented in how you organize and nest information in your documents.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">While you can choose any structure for your documents, the JSON model in particular will help you organize your information in a standard way, and enable you to take advantage of Couchbase Server&#8217;s ability to index and query. As a developer you benefit in several ways from this approach:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Extend the schema at run time, or anytime. You can add new fields for a type of item anytime. Changes to your schema can be tracked by a version number, or by other fields as needed.<\/li>\n\n\n<li>Document-based data models may better represent the information you want to store and the data structures you need in your application.<\/li>\n\n\n<li>You design your application information in documents, rather than model your data for a database.<\/li>\n\n\n<li>Converting application information into JSON is very simple; there are many options, and there are many libraries widely available for JSON conversion.<\/li>\n\n\n<li>Minimization of one-to-many relationships through use of nested entities and therefore, reduction of joins.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">There are several considerations to have in mind when you design your JSON document:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>What particular keys, ids, prefixes or conventions you want to use for items, for instance <strong>beer_My_Brew<\/strong>.<\/li>\n\n\n<li>When you want a document to expire, if at all, and what expiration would be best.<\/li>\n\n\n<li>If want to use a document to access other documents. In other words, you can store keys that refer other documents in a JSON document and get the keys through this document. In the NoSQL database jargon, this is often known as using <em>composite keys<\/em>.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">You can group together sets of records into collections. For example, the following JSON document could be in the &#8220;beers&#8221; collection. A document that represents another kind of entity would be in a different collection, such as <em>brewery<\/em> o <em>user<\/em>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-json\"><code>{\n  &quot;beer_id&quot;: &quot;beer_Hoptimus_Prime&quot;,\n  &quot;abv&quot;: 10,\n  &quot;category&quot;: &quot;North American Ale&quot;,\n  &quot;name&quot;: &quot;Hoptimus Prime&quot;,\n  &quot;style&quot;: &quot;Double India Pale Ale&quot;\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here is another document in the <em>breweries<\/em> collection:<\/p>\n\n\n\n<pre class=\"wp-block-code language-json\"><code>{\n  &quot;brewery_id&quot;: &quot;brewery_Legacy_Brewing_Co&quot;,\n  &quot;name&quot;: &quot;Legacy Brewing Co.&quot;,\n  &quot;address&quot;: &quot;525 Canal Street, Reading, Pennsylvania, 19601 United States&quot;,\n  &quot;updated&quot;: &quot;2010-07-22 20:00:20&quot;\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">What happens if we want to change the fields we store for a brewery? Add the fields to brewery documents. In this case we decide later that we want to include GPS location of the brewery:<\/p>\n\n\n\n<pre class=\"wp-block-code language-json\"><code>{\n  &quot;brewery_id&quot;: &quot;brewery_Legacy_Brewing_Co&quot;,\n  &quot;name&quot;: &quot;Legacy Brewing Co.&quot;,\n  &quot;address&quot;: &quot;525 Canal Street, Reading, Pennsylvania, 19601 United States&quot;,\n  &quot;updated&quot;: &quot;2010-07-22 20:00:20&quot;,\n  &quot;latitude&quot;: -75.928469,\n  &quot;longitude&quot;: 40.325725\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the case of document-based data, we extend the record by just adding the two new fields for <em>latitude<\/em> e <em>longitude<\/em>. When we add other breweries after this one, we would include these two new fields. For older breweries we can update them with the new fields or provide programming logic that shows a default for older breweries. The best approach for adding new fields to a document is to perform a compare and swap operation on the document to change it; with this type of operation, Couchbase will send you a message that the data has already changed if someone has already changed the record. For more information about compare and swap methods with Couchbase, see <a href=\"https:\/\/docs.couchbase.com\/java-sdk\/current\/howtos\/concurrent-document-mutations.html\">Compare and Swap (CAS)<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To create relationships between items, we again use fields. In this example we create a logical connection between beers and breweries using the <em>brewery<\/em> field in our beer document which relates to the <em>ID<\/em> field in the brewery document. This is analogous to the idea of using a foreign key in traditional relational database design.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This first document represents a beer, Hoptimus Prime:<\/p>\n\n\n\n<pre class=\"wp-block-code language-json\"><code>{\n  &quot;beer_id&quot;: &quot;beer_Hoptimus_Prime&quot;,\n  &quot;abv&quot;: 10,\n  &quot;brewery&quot;: &quot;brewery_Legacy_Brewing_Co&quot;,\n  &quot;category&quot;: &quot;North American Ale&quot;,\n  &quot;name&quot;: &quot;Hoptimus Prime&quot;,\n  &quot;style&quot;: &quot;Double India Pale Ale&quot;\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This second document represents the brewery which brews Hoptimus Prime:<\/p>\n\n\n\n<pre class=\"wp-block-code language-json\"><code>{\n  &quot;brewery_id&quot;: &quot;brewery_Legacy_Brewing_Co&quot;,\n  &quot;name&quot;: &quot;Legacy Brewing Co.&quot;,\n  &quot;address&quot;: &quot;525 Canal Street Reading, Pennsylvania, 19601 United States&quot;,\n  &quot;updated&quot;: &quot;2010-07-22 20:00:20&quot;,\n  &quot;latitude&quot;: -75.928469,\n  &quot;longitude&quot;: 40.325725\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In our beer document, the <em>brewery<\/em> field points to &#8216;<strong>brewery_Legacy_Brewery_Co<\/strong>&#8216;, which is the key for the document that represents the brewery. By using this model of referencing documents within a document, we create relationships between application objects.<\/p>","protected":false},"excerpt":{"rendered":"<p>When you use documents to represent data, a database schema is optional. The majority of your effort will be creating one or more documents that will represent application data. This document structure can evolve over time as your application grows and adds new features. In Couchbase Server you do not need to perform data modeling [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false,"_acf":"","inline_featured_image":false,"footnotes":""},"tutorial-languages":[551],"tutorial-tags":[565],"tutorial-technologies":[562,548,554],"tutorial-types":[555],"class_list":["post-10223","tutorials","type-tutorials","status-publish","hentry","tutorial-languages-any","tutorial-tags-data-modeling","tutorial-technologies-capella","tutorial-technologies-kv","tutorial-technologies-server","tutorial-types-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.9 (Yoast SEO v28.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Schemaless Data Modeling - Couchbase<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/it\/developers\/tutorials\/schemaless-data-modeling\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Schemaless Data Modeling\" \/>\n<meta property=\"og:description\" content=\"When you use documents to represent data, a database schema is optional. The majority of your effort will be creating one or more documents that will represent application data. This document structure can evolve over time as your application grows and adds new features. In Couchbase Server you do not need to perform data modeling [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/it\/developers\/tutorials\/schemaless-data-modeling\/\" \/>\n<meta property=\"og:site_name\" content=\"Couchbase\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Couchbase\/\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/10\/Cloud-2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2548\" \/>\n\t<meta property=\"og:image:height\" content=\"1171\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@couchbase\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/it\\\/developers\\\/tutorials\\\/schemaless-data-modeling\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/it\\\/developers\\\/tutorials\\\/schemaless-data-modeling\\\/\",\"name\":\"Schemaless Data Modeling - Couchbase\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/it\\\/#website\"},\"datePublished\":\"2025-08-04T15:56:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/it\\\/developers\\\/tutorials\\\/schemaless-data-modeling\\\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/it\\\/developers\\\/tutorials\\\/schemaless-data-modeling\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/it\\\/developers\\\/tutorials\\\/schemaless-data-modeling\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/ko\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Schemaless Data Modeling\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/it\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/it\\\/\",\"name\":\"Couchbase\",\"description\":\"The Operational Data Platform for AI\u2122\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/it\\\/#organization\"},\"alternateName\":\"Couchbase, Inc.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/it\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/it\\\/#organization\",\"name\":\"Couchbase\",\"alternateName\":\"Couchbase, Inc.\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/it\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/it\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Couchbase_Logo_Couchbase_Token_Red-1.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Couchbase_Logo_Couchbase_Token_Red-1.png\",\"width\":1129,\"height\":1129,\"caption\":\"Couchbase\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/it\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Couchbase\\\/\",\"https:\\\/\\\/x.com\\\/couchbase\",\"https:\\\/\\\/www.youtube.com\\\/c\\\/CouchbaseServer\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/couchbase\\\/\",\"https:\\\/\\\/github.com\\\/couchbase\\\/\",\"https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Couchbase,_Inc.\"],\"description\":\"Couchbase is a database software company headquartered in San Jose, California, providing an operational data platform for AI used by hundreds of global enterprises.\",\"legalName\":\"Couchbase, Inc.\",\"foundingDate\":\"2011-01-01\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Schemaless Data Modeling - Couchbase","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/it\/developers\/tutorials\/schemaless-data-modeling\/","og_locale":"it_IT","og_type":"article","og_title":"Schemaless Data Modeling","og_description":"When you use documents to represent data, a database schema is optional. The majority of your effort will be creating one or more documents that will represent application data. This document structure can evolve over time as your application grows and adds new features. In Couchbase Server you do not need to perform data modeling [&hellip;]","og_url":"https:\/\/www.couchbase.com\/it\/developers\/tutorials\/schemaless-data-modeling\/","og_site_name":"Couchbase","article_publisher":"https:\/\/www.facebook.com\/Couchbase\/","og_image":[{"width":2548,"height":1171,"url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/10\/Cloud-2.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@couchbase","twitter_misc":{"Est. reading time":"4 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/it\/developers\/tutorials\/schemaless-data-modeling\/","url":"https:\/\/www.couchbase.com\/it\/developers\/tutorials\/schemaless-data-modeling\/","name":"Schemaless Data Modeling - Couchbase","isPartOf":{"@id":"https:\/\/www.couchbase.com\/it\/#website"},"datePublished":"2025-08-04T15:56:24+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/it\/developers\/tutorials\/schemaless-data-modeling\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/it\/developers\/tutorials\/schemaless-data-modeling\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/it\/developers\/tutorials\/schemaless-data-modeling\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/ko\/"},{"@type":"ListItem","position":2,"name":"Schemaless Data Modeling"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/it\/#website","url":"https:\/\/www.couchbase.com\/it\/","name":"Couchbase","description":"The Operational Data Platform for AI\u2122","publisher":{"@id":"https:\/\/www.couchbase.com\/it\/#organization"},"alternateName":"Couchbase, Inc.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/it\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"it-IT"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/it\/#organization","name":"Couchbase","alternateName":"Couchbase, Inc.","url":"https:\/\/www.couchbase.com\/it\/","logo":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/www.couchbase.com\/it\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Couchbase_Logo_Couchbase_Token_Red-1.png","contentUrl":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Couchbase_Logo_Couchbase_Token_Red-1.png","width":1129,"height":1129,"caption":"Couchbase"},"image":{"@id":"https:\/\/www.couchbase.com\/it\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Couchbase\/","https:\/\/x.com\/couchbase","https:\/\/www.youtube.com\/c\/CouchbaseServer","https:\/\/www.linkedin.com\/company\/couchbase\/","https:\/\/github.com\/couchbase\/","https:\/\/en.wikipedia.org\/wiki\/Couchbase,_Inc."],"description":"Couchbase \u00e8 una societ\u00e0 di software per database con sede a San Jose, in California, che fornisce una piattaforma operativa per i dati utilizzata da centinaia di aziende globali.","legalName":"Couchbase, Inc.","foundingDate":"2011-01-01"}]}},"permalink_manager":null,"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/it\/wp-json\/wp\/v2\/tutorials\/10223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/it\/wp-json\/wp\/v2\/tutorials"}],"about":[{"href":"https:\/\/www.couchbase.com\/it\/wp-json\/wp\/v2\/types\/tutorials"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/it\/wp-json\/wp\/v2\/tutorials\/10223\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/it\/wp-json\/wp\/v2\/media?parent=10223"}],"wp:term":[{"taxonomy":"tutorial-languages","embeddable":true,"href":"https:\/\/www.couchbase.com\/it\/wp-json\/wp\/v2\/tutorial-languages?post=10223"},{"taxonomy":"tutorial-tags","embeddable":true,"href":"https:\/\/www.couchbase.com\/it\/wp-json\/wp\/v2\/tutorial-tags?post=10223"},{"taxonomy":"tutorial-technologies","embeddable":true,"href":"https:\/\/www.couchbase.com\/it\/wp-json\/wp\/v2\/tutorial-technologies?post=10223"},{"taxonomy":"tutorial-types","embeddable":true,"href":"https:\/\/www.couchbase.com\/it\/wp-json\/wp\/v2\/tutorial-types?post=10223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}