<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NoSQL - TheCodeBuzz</title>
	<atom:link href="https://thecodebuzz.com/category/nosql/feed/" rel="self" type="application/rss+xml" />
	<link>https://thecodebuzz.com</link>
	<description>Best Practices for Software Development</description>
	<lastBuildDate>Sat, 09 Mar 2024 22:09:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://thecodebuzz.com/wp-content/uploads/2022/11/cropped-android-chrome-512x512-1-1-51x51.jpg</url>
	<title>NoSQL - TheCodeBuzz</title>
	<link>https://thecodebuzz.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>What is Data Modelling &#8211; Fundamentals and Guidelines</title>
		<link>https://thecodebuzz.com/what-is-data-modelling-fundamentals-sql-nosql-guidelines/</link>
					<comments>https://thecodebuzz.com/what-is-data-modelling-fundamentals-sql-nosql-guidelines/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 25 Nov 2023 22:59:31 +0000</pubDate>
				<category><![CDATA[Database Best Practices]]></category>
		<category><![CDATA[Design Pattern]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Data Modelling - Fundamentals and Guidelines]]></category>
		<guid isPermaLink="false">https://www.thecodebuzz.com/?p=28855</guid>

					<description><![CDATA[<p>What is Data Modelling &#8211; Fundamentals and Guidelines Today in this article, we will go over Data Modelling &#8211; Fundamentals and Building Blocks and their usage guidelines. What is Data Modelling Data modeling is an important technique for effective database design, understanding the data requirements of a particular use case, and offering a structured method [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/what-is-data-modelling-fundamentals-sql-nosql-guidelines/">What is Data Modelling – Fundamentals and Guidelines</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading">What is Data Modelling &#8211; Fundamentals and Guidelines</h1>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="666" height="324" src="https://www.thecodebuzz.com/wp-content/uploads/2023/11/what-is-data-modelling-fundamentals-sql-nosql-guidelines.jpg" alt="What is Data Modelling - Fundamentals and Guidelines" class="wp-image-29209" srcset="https://thecodebuzz.com/wp-content/uploads/2023/11/what-is-data-modelling-fundamentals-sql-nosql-guidelines.jpg 666w, https://thecodebuzz.com/wp-content/uploads/2023/11/what-is-data-modelling-fundamentals-sql-nosql-guidelines-300x146.jpg 300w" sizes="(max-width: 666px) 100vw, 666px" /></figure>



<p>Today in this article, we will go over Data Modelling &#8211; Fundamentals and Building Blocks and their usage guidelines.</p>



<p></p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-what-is-data-modelling">What is Data Modelling</a></li><li><a href="#aioseo-sql-and-no-sql-data-modelling-is-still-valid-techniques">SQL and NO SQL &#8211; Data modeling is still a valid technique</a></li><li><a href="#aioseo-type-of-data-dodeling-concepts">Type of Data Modeling Concepts</a><ul><li><a href="#aioseo-conceptual-data-modeling">Conceptual Data Modeling</a></li><li><a href="#aioseo-logical-data-modeling">Logical Data Modeling</a></li><li><a href="#aioseo-physical-data-modeling">Physical Data Modeling:</a></li></ul></li><li><a href="#aioseo-building-blocks-of-data-modeling">Building blocks of Data modeling</a><ul><li><a href="#aioseo-entities-in-data-modelling">Entities in Data Modelling</a></li><li><a href="#aioseo-attributes-in-data-modelling">Attributes in Data Modelling</a></li><li><a href="#aioseo-relationships-in-data-modeling">Relationships in Data modeling</a></li><li><a href="#aioseo-keys-in-data-modeling">Keys in Data modeling</a></li><li><a href="#aioseo-benefits-of-data-modeling">Benefits of Data Modeling</a></li><li><a href="#aioseo-data-modeling-tools">Data modeling Tools</a></li></ul></li></ul></div>



<p></p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-what-is-data-modelling">What is Data Modelling </h2>



<p></p>



<p><a href="https://www.thecodebuzz.com/mongodb-schema-design-guidelines-best-practices/" target="_blank" rel="noopener" title="MongoDB Schema Design – Guidelines and Best practices">Data modeling</a> is an important technique for effective database design, understanding the data requirements of a particular use case, and offering a structured method for understanding, representing, and implementing data structures for a given requirement.</p>



<p></p>



<p>Data Modelling normally occurs at the beginning of the development process to understand and document business requirements before database implementation. </p>



<p></p>



<p>This means it heavily helps you identify and documentation of business logic, rules, and relationships to ensure that the data model aligns with business objectives.</p>



<p></p>



<p>Data modeling focuses on organizing data at a <strong>Conceptual </strong>or <strong>Abstract or </strong> <strong>Physical </strong>level. </p>



<p></p>



<p>It aims to understand the information requirements of a business or system and define the relationships between different data entities. </p>



<p></p>



<p>Data modeling utilizes techniques like Entity-Relationship Diagrams (<strong>ERD</strong>) to represent entities, attributes, and relationships between entities, but this evolution and brainstorming does help you define your requirements in a true sense. </p>



<p></p>



<p>Along with facilitating discussions, it ensures changes to the design are visited during the early stages of development. In the world of development, which fully relies on design in the first place this does help in a greater way.</p>



<p></p>



<p>Data Modelling encourages communication between various stakeholders including the product owner, scrum, developers, or architects by providing a visual representation of data concepts that is accessible to both technical and non-technical audiences.</p>



<p></p>



<p>It very good technique for extending logical and physical design, normalization, relationship mapping, and performance optimization at the very beginning of use case or requirements explorations.</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-sql-and-no-sql-data-modelling-is-still-valid-techniques">SQL and NO SQL &#8211; Data modeling is still a valid technique</h2>



<p></p>



<p>Data Modelling operates at a more elevated level of <strong>abstraction</strong>, stressing entities, attributes, and relationships without getting into specific database implementation details, and hence this technique&#8217;s value holds for SQL or No SQL database design.</p>



<p> </p>



<p>The outcomes of Data modeling ensure conceptualization, understanding, and representation of data requirements to various stake stakeholders and hence build confidence in the product which is going to evolve later stage as deliverables.</p>



<p></p>



<p></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="278" src="https://www.thecodebuzz.com/wp-content/uploads/2023/11/Data-Modelling-vs-schema-modelling-1024x278.jpg" alt="" class="wp-image-28859" srcset="https://thecodebuzz.com/wp-content/uploads/2023/11/Data-Modelling-vs-schema-modelling-1024x278.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2023/11/Data-Modelling-vs-schema-modelling-300x81.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2023/11/Data-Modelling-vs-schema-modelling-768x208.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2023/11/Data-Modelling-vs-schema-modelling-1536x417.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2023/11/Data-Modelling-vs-schema-modelling-785x213.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2023/11/Data-Modelling-vs-schema-modelling.jpg 1770w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<h2 class="wp-block-heading" id="aioseo-type-of-data-dodeling-concepts">Type of Data Modeling Concepts</h2>



<p></p>



<h3 class="wp-block-heading" id="aioseo-conceptual-data-modeling"><strong>Conceptual Data Modeling</strong></h3>



<p></p>



<ul class="wp-block-list">
<li>Focuses on the high-level representation of the domain entities, business concepts, and relationships within a system.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>Helps in getting all the the fundamental entities, attributes, and relationships between.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>Provide a clear and abstract view of the business requirements, serving as a foundation for further development.</li>
</ul>



<p></p>



<h3 class="wp-block-heading" id="aioseo-logical-data-modeling"><strong>Logical Data Modeling</strong></h3>



<p></p>



<ul class="wp-block-list">
<li>This modeling helps translate the conceptual data model into a more detailed and structured format that can be implemented in a database.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>Defines tables, columns, fields, data types, relationships, and constraints for the given database management system.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>It acts as a bridge between the conceptual model and the physical implementation, ensuring a comprehensive and consistent representation of data.</li>
</ul>



<p></p>



<p></p>



<h3 class="wp-block-heading" id="aioseo-physical-data-modeling"><strong>Physical Data Modeling:</strong></h3>



<p></p>



<p></p>



<ul class="wp-block-list">
<li>Focuses on the actual implementation of the database on a specific database management system SQL or  No SQL.</li>
</ul>



<p></p>



<p></p>



<ul class="wp-block-list">
<li>Includes details such as storage structures, indexing, partitioning, and other optimization techniques to enhance performance.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>Involves decisions about how data is stored, accessed, and retrieved at the physical level, considering the specific features and requirements of the chosen DBMS.</li>
</ul>



<p></p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-building-blocks-of-data-modeling"><strong>Building blocks of Data modeling </strong></h2>



<p></p>



<h3 class="wp-block-heading" id="aioseo-entities-in-data-modelling">Entities in Data Modelling </h3>



<p></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="684" height="540" src="https://www.thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Fundamentals.jpg" alt="" class="wp-image-28860" style="aspect-ratio:1.2666666666666666;width:683px;height:auto" srcset="https://thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Fundamentals.jpg 684w, https://thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Fundamentals-300x237.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Fundamentals-659x520.jpg 659w" sizes="(max-width: 684px) 100vw, 684px" /></figure>



<p></p>



<p>The best way to judge an entity is as some type of &#8220;<strong><em>real-world subject</em></strong>.&#8221;</p>



<p></p>



<p>At the end entity represents &#8221; <strong><em>a collection of attributes or fields</em></strong>.&#8221;</p>



<p></p>



<p>Entities represent distinct objects, concepts, or things within a system that are described and stored as data. </p>



<p></p>



<p>These entities encapsulate relevant information through attributes, defining the properties or characteristics associated with them. </p>



<p></p>



<p>For example, in a customer relationship system, a &#8220;Customer&#8221; entity might include attributes such as &#8220;CustomerID,&#8221; &#8220;Name,&#8221; and &#8220;Email.&#8221; </p>



<p></p>



<p>Identifying and modeling entities is foundational for a clear understanding of the information requirements and relationships within a given domain or system.</p>



<p></p>



<p></p>



<h3 class="wp-block-heading" id="aioseo-attributes-in-data-modelling">Attributes in Data Modelling </h3>



<p></p>



<p>Attributes provide granularity to the data model, offering a way to distinguish and categorize information within entities.</p>



<p></p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="862" height="434" src="https://www.thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Entity-Data-Model-and-attribute-examples.jpg" alt="Data Modelling Fundamentals and Building Blocks" class="wp-image-28865" style="aspect-ratio:1.9861751152073732;width:840px;height:auto" srcset="https://thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Entity-Data-Model-and-attribute-examples.jpg 862w, https://thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Entity-Data-Model-and-attribute-examples-300x151.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Entity-Data-Model-and-attribute-examples-768x387.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Entity-Data-Model-and-attribute-examples-785x395.jpg 785w" sizes="auto, (max-width: 862px) 100vw, 862px" /></figure>



<p>By defining these attributes, data modeling achieves a more comprehensive representation of the underlying data, enabling the organization and retrieval of specific details associated with each entity in a structured and meaningful manner.</p>



<p></p>



<p>Characteristics or properties of <a href="https://www.thecodebuzz.com/getting-started-efcore-entity-framework-core-orm-asp-net-core/" target="_blank" rel="noopener" title="Getting Started with Entity Framework – ORM in ASP.NET Core">entities </a>that describe the data associated with them. </p>



<p></p>



<p>Attributes provide details about the entities and are often represented as adjectives, like &#8220;<strong>Name</strong>&#8221; or &#8220;<strong>DateOfBirth</strong>.&#8221;</p>



<p></p>



<p></p>



<h3 class="wp-block-heading" id="aioseo-relationships-in-data-modeling">Relationships in Data modeling</h3>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="706" height="607" src="https://www.thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Fundamentals-attributes-and-relationship.jpg" alt="" class="wp-image-28864" srcset="https://thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Fundamentals-attributes-and-relationship.jpg 706w, https://thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Fundamentals-attributes-and-relationship-300x258.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Fundamentals-attributes-and-relationship-605x520.jpg 605w" sizes="auto, (max-width: 706px) 100vw, 706px" /></figure>



<p>In data modeling, relationships establish <a href="https://www.thecodebuzz.com/database-connection-resiliency-entity-framework-asp-net-core/">connections between entities,</a> defining how they interact. T</p>



<p></p>



<p>These connections convey associations and dependencies, crucial for understanding the dynamics within a system. </p>



<p></p>



<p>For instance, in a database for a library, a &#8220;Customer&#8221; entity may have a relationship with an &#8220;Order&#8221; entity, indicating the association between individuals requesting an order. </p>



<p></p>



<ul class="wp-block-list">
<li>Relationships specify the cardinality and nature of connections, such as one-to-one or many-to-many, providing a structured framework for data representation. </li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>By modeling relationships, data modeling ensures a comprehensive understanding of how entities relate to one another, fostering accurate and efficient retrieval of information from the database.</li>
</ul>



<p></p>



<p></p>



<h3 class="wp-block-heading" id="aioseo-keys-in-data-modeling">Keys in Data modeling</h3>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="722" height="659" src="https://www.thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Fundamentals-relationship-and-keys-defined.jpg" alt="" class="wp-image-28868" srcset="https://thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Fundamentals-relationship-and-keys-defined.jpg 722w, https://thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Fundamentals-relationship-and-keys-defined-300x274.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2023/11/Mastering-Data-Modeling-Fundamentals-relationship-and-keys-defined-570x520.jpg 570w" sizes="auto, (max-width: 722px) 100vw, 722px" /></figure>



<ul class="wp-block-list">
<li>Keys play a pivotal role in data modeling by uniquely identifying and organizing data within a database.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li><strong>In RDBMS or SQL </strong>worlds example &#8211; the &#8220;primary key&#8221; serves as a distinct identifier for each record, ensuring data integrity.
<ul class="wp-block-list">
<li>Foreign keys establish relationships between tables, linking data across entities. </li>



<li>Index keys enhance query performance, enabling swift data retrieval.</li>



<li>Composite keys combine multiple attributes to create a unique identifier.</li>
</ul>
</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>In <strong>No SQL</strong> Unique Keys identify documents or entries within a collection, ensuring data integrity.
<ul class="wp-block-list">
<li>In document-oriented databases, like MongoDB, keys often include a unique identifier, such as the document&#8217;s &#8220;_id.&#8221;</li>



<li>In key-value stores, like Redis, keys serve as direct access points to values.</li>



<li>NoSQL databases may also use composite keys or secondary indexes for diverse query patterns.</li>



<li>Keys are crucial for optimizing data access, retrieval, and navigation in NoSQL databases, contributing to performance in managing various data structures and relationships.</li>
</ul>
</li>
</ul>



<p></p>



<h3 class="wp-block-heading" id="aioseo-benefits-of-data-modeling">Benefits of Data Modeling</h3>



<p></p>



<p>Below are the top-level benefits of data modeling.</p>



<p></p>



<ul class="wp-block-list">
<li>Creating a structure for collaboration between your IT and business teams.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>Revealing opportunities for improving business processes by defining data needs and uses.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>Saving time and money on IT and process investments through appropriate planning.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>Reducing errors (and error-prone redundant data entry) while improving data integrity.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>Increasing the speed and performance of data retrieval and analytics by planning for capacity and growth.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>Setting and tracking target key performance indicators tailored to your business objectives.</li>
</ul>



<p></p>



<h3 class="wp-block-heading" id="aioseo-data-modeling-tools"><strong>Data modeling Tools</strong></h3>



<p></p>



<p>Here are a few useful tools for Data modeling examples:</p>



<p></p>



<ul class="wp-block-list">
<li><strong>erwin Data Modeler</strong> is a data modeling tool based on the Integration DEFinition for information modeling (IDEF1X) data modeling language that now supports other notation methodologies, including a dimensional approach.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li><strong>Enterprise Architect</strong> is a visual modeling and design tool that supports the modeling of enterprise information systems and architectures. It’s based on object-oriented languages and standards.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li><strong>ER/Studio</strong> is database design software that’s compatible with several of today’s most popular database management systems. It supports both relational and dimensional data modeling.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li><strong>Open Source tools</strong> include open-source solutions such as Open ModelSphere.</li>
</ul>



<p></p>



<p></p>



<p>That&#8217;s all! Happy coding!</p>



<p></p>



<p>Does this help you fix your issue? </p>



<p></p>



<p>Do you have any better solutions or suggestions? Please sound off your comments below.</p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p>



<p></p><p>The post <a href="https://thecodebuzz.com/what-is-data-modelling-fundamentals-sql-nosql-guidelines/">What is Data Modelling – Fundamentals and Guidelines</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/what-is-data-modelling-fundamentals-sql-nosql-guidelines/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Concatenate Texts from Multiple Rows in SQL</title>
		<link>https://thecodebuzz.com/concatenate-texts-from-multiple-rows-in-sql/</link>
					<comments>https://thecodebuzz.com/concatenate-texts-from-multiple-rows-in-sql/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sun, 19 Mar 2023 01:01:45 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Concatenate Texts from Multiple Rows in SQL]]></category>
		<guid isPermaLink="false">https://www.thecodebuzz.com/?p=26403</guid>

					<description><![CDATA[<p>Concatenate texts from multiple rows in SQL Today in this article, we will see how to Concatenate texts from multiple rows in SQL. It&#8217;s pretty simple to combine multiple rows in SQL and create Concatenate texts using the STRING_AGG function. Let&#8217;s take an example below. Here I have a sample table with the Bank code [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/concatenate-texts-from-multiple-rows-in-sql/">Concatenate Texts from Multiple Rows in SQL</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading"><strong>Concatenate texts from multiple rows in SQL</strong></h1>



<figure class="wp-block-image size-full"><a href="https://www.thecodebuzz.com/concatenate-texts-from-multiple-rows-in-sql/" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="710" height="373" src="https://www.thecodebuzz.com/wp-content/uploads/2023/03/convert-multiple-rows-into-one-with-comma-as-separator.jpg" alt="" class="wp-image-26410" srcset="https://thecodebuzz.com/wp-content/uploads/2023/03/convert-multiple-rows-into-one-with-comma-as-separator.jpg 710w, https://thecodebuzz.com/wp-content/uploads/2023/03/convert-multiple-rows-into-one-with-comma-as-separator-300x158.jpg 300w" sizes="auto, (max-width: 710px) 100vw, 710px" /></a></figure>



<p>Today in this article, we will see how to Concatenate texts from multiple rows in SQL.</p>



<p></p>



<p>It&#8217;s pretty simple to combine multiple rows in SQL and create Concatenate texts using the STRING_AGG function.</p>



<p></p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-example">Example</a></li><li><a href="#aioseo-expected-output">Expected output</a></li><li><a href="#aioseo-command">What is STRING_AGG</a></li><li><a href="#aioseo-command">Command</a></li></ul></div>



<p></p>



<p>Let&#8217;s take an example below. Here I have a sample table with the Bank code and Name of the employee matching the bank code.</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-example"><strong>Example </strong></h2>



<p></p>



<figure class="wp-block-image size-full"><a href="https://www.thecodebuzz.com/concatenate-texts-from-multiple-rows-in-sql" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="474" height="400" src="https://www.thecodebuzz.com/wp-content/uploads/2023/03/concatenate-text-from-multiple-rows-into-a-single-text-string-in-sql.jpg" alt="Concatenate texts from multiple rows in SQL" class="wp-image-26404" srcset="https://thecodebuzz.com/wp-content/uploads/2023/03/concatenate-text-from-multiple-rows-into-a-single-text-string-in-sql.jpg 474w, https://thecodebuzz.com/wp-content/uploads/2023/03/concatenate-text-from-multiple-rows-into-a-single-text-string-in-sql-300x253.jpg 300w" sizes="auto, (max-width: 474px) 100vw, 474px" /></a></figure>



<h2 class="wp-block-heading" id="aioseo-expected-output">Expected output </h2>



<p></p>



<p>Here we will try to get out as below,</p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">FC100   X, Y, Z
FC345   A, P, S</pre>



<p></p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-command">What is STRING_AGG</h2>



<p></p>



<ul class="wp-block-list">
<li>The aggregate function STRING AGG concatenates every expression from every row into a single string.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>The implicit conversion of expression values to string types is done before concatenation.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>The implicit conversion to strings adheres to the standards for converting data types.</li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-command">Command </h2>



<p></p>



<pre class="wp-block-preformatted">STRING_AGG ( expression, separator ) [ &lt;order_clause&gt; ] &lt;order_clause&gt; ::= WITHIN GROUP ( ORDER BY &lt;order_by_expression_list&gt; [ ASC | DESC ] )</pre>



<p></p>



<p>Example:</p>



<p></p>



<p></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="402" src="https://www.thecodebuzz.com/wp-content/uploads/2023/03/concatenate-text-from-multiple-rows-into-single-text-string-in-sql-1024x402.jpg" alt="STRING_AGG " class="wp-image-26405" srcset="https://thecodebuzz.com/wp-content/uploads/2023/03/concatenate-text-from-multiple-rows-into-single-text-string-in-sql-1024x402.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2023/03/concatenate-text-from-multiple-rows-into-single-text-string-in-sql-300x118.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2023/03/concatenate-text-from-multiple-rows-into-single-text-string-in-sql-768x302.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2023/03/concatenate-text-from-multiple-rows-into-single-text-string-in-sql-785x308.jpg 785w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p></p>



<p></p>



<p style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size"></p>



<p style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size"></p>



<p class="has-medium-font-size"><strong>Happy Coding </strong>!!</p>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p>



<p></p><p>The post <a href="https://thecodebuzz.com/concatenate-texts-from-multiple-rows-in-sql/">Concatenate Texts from Multiple Rows in SQL</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/concatenate-texts-from-multiple-rows-in-sql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>MongoDB nested array string field value length query</title>
		<link>https://thecodebuzz.com/mongodb-nested-array-string-field-value-length-query/</link>
					<comments>https://thecodebuzz.com/mongodb-nested-array-string-field-value-length-query/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 25 Jan 2023 05:31:04 +0000</pubDate>
				<category><![CDATA[Node.js]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[mongodb field length limit]]></category>
		<category><![CDATA[mongodb filter by length of string]]></category>
		<category><![CDATA[mongodb length of string greater than]]></category>
		<category><![CDATA[mongodb length of string in array]]></category>
		<category><![CDATA[mongodb nested array length]]></category>
		<category><![CDATA[mongodb nested array of objects]]></category>
		<category><![CDATA[mongodb sort by length of string]]></category>
		<category><![CDATA[mongodb string length less than]]></category>
		<guid isPermaLink="false">https://www.thecodebuzz.com/?p=25957</guid>

					<description><![CDATA[<p>MongoDB nested array string field value length query Today this article will see how to write a MongoDB nested array string field value length query. Today in this article, we will cover below aspects, We will cover below query types, We shall see examples for MongoDB field query where we will get the records based [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/mongodb-nested-array-string-field-value-length-query/">MongoDB nested array string field value length query</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading">MongoDB nested array string field value length query</h1>



<figure class="wp-block-image size-large is-resized"><a href="https://www.thecodebuzz.com/mongodb-string-field-value-length-query-greater-than/" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="1024" height="292" src="https://www.thecodebuzz.com/wp-content/uploads/2020/12/MongoDB-Date-Range-query-greater-than-or-lesss-than-Date-C-query-1024x292.jpg" alt="MongoDB string field value length query,mongodb length of string greater than,
mongodb filter by length of string,
mongodb length of string in array,
<a href=" class="wp-image-13556" srcset="https://thecodebuzz.com/wp-content/uploads/2020/12/MongoDB-Date-Range-query-greater-than-or-lesss-than-Date-C-query-1024x292.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2020/12/MongoDB-Date-Range-query-greater-than-or-lesss-than-Date-C-query-300x86.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2020/12/MongoDB-Date-Range-query-greater-than-or-lesss-than-Date-C-query-768x219.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2020/12/MongoDB-Date-Range-query-greater-than-or-lesss-than-Date-C-query-1536x438.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2020/12/MongoDB-Date-Range-query-greater-than-or-lesss-than-Date-C-query-785x224.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2020/12/MongoDB-Date-Range-query-greater-than-or-lesss-than-Date-C-query.jpg 1633w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></figure>



<p>Today this article will see how to write a MongoDB nested array string field value length query.</p>



<p></p>



<p>Today in this article, we will cover below aspects,</p>



<p></p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-getting-started">Getting started</a></li><li><a href="#aioseo-mongo-field-length-query-using-cli-or-compass-ui">Mongo field length query using Mongo Shell or Compass UI</a><ul><li><a href="#aioseo-mongodb-string-field-value-length-greater-than-query">MongoDB nested array string field value greater than query ></a></li><li><a href="#aioseo-mongodb-string-field-value-length-less-than-query">MongoDB nested Array field string value length less than query <</a></li><li><a href="#aioseo-mongodb-string-field-value-length-equal-to-length">MongoDB nested Array field string value length Equal to length =</a></li></ul></li><li><a href="#aioseo-using-regex">Using Regex &#8211; MongoDB nested array string field value length query</a></li></ul></div>



<p></p>



<p>We will cover below query types,</p>



<p></p>



<ul class="wp-block-list">
<li>Greater than field value length </li>
</ul>



<ul class="wp-block-list">
<li>Less than field value length </li>
</ul>



<ul class="wp-block-list">
<li>Equal to the length of the field value</li>
</ul>



<p></p>



<p>We shall see examples for MongoDB field query where we will get the records based on field length value greater than or less than of specified value. <span style="font-size: revert; color: initial;">We will run field-length queries</span> using CLI or  Compass UI<span style="font-size: revert; color: initial;">.</span></p>



<p></p>



<p>We already looked at a simple way of adding or updating a new field to the document in our previous <strong><a href="https://www.thecodebuzz.com/mongodb-add-new-field-every-document-in-mongodb-collection/" target="_blank" rel="noreferrer noopener">MongoDB sample series</a>. </strong></p>



<p></p>



<p>We shall also see how to create a similar query using other languages like C# mongo driver.</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-getting-started">Getting started</h2>



<p></p>



<p>Here below is a sample schema or document we shall use for array object with field length query and will cover less than or greater than length query for field value &#8220;Books.category.value&#8221; field.</p>



<p></p>



<p>Below by value field is of type string and we will get all records where such field length is less than or greater than the specified size.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="783" src="https://www.thecodebuzz.com/wp-content/uploads/2023/01/MongoDB-nested-array-field-value-length-query-greater-than-less-than-1024x783.jpg" alt="" class="wp-image-25959" srcset="https://thecodebuzz.com/wp-content/uploads/2023/01/MongoDB-nested-array-field-value-length-query-greater-than-less-than-1024x783.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2023/01/MongoDB-nested-array-field-value-length-query-greater-than-less-than-300x229.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2023/01/MongoDB-nested-array-field-value-length-query-greater-than-less-than-768x587.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2023/01/MongoDB-nested-array-field-value-length-query-greater-than-less-than-680x520.jpg 680w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<h2 class="wp-block-heading" id="aioseo-mongo-field-length-query-using-cli-or-compass-ui">Mongo field length query using Mongo Shell or Compass UI </h2>



<p></p>



<p>Here we will be using the below query to get the documents based on the value of the length of fields in the MongoDB Collection.</p>



<p>Nested array element finding and then getting its length can be done easily using below simple query as explained.</p>



<p></p>



<p><strong><em>Pattern</em>:</strong></p>



<p></p>



<pre id="block-0c76aa9e-4113-436b-874c-263dc8417774" class="wp-block-preformatted has-medium-font-size">{
  "$expr": {
    "$anyElementTrue": {
      "$map": {
        "input": {
          "$reduce": {
            "input": "$&lt;YourFieldName(fully qualified field)&gt;",
            "initialValue": [],
            "in": { "$concatArrays": [ "$$&lt;YourFieldName&gt;", "$$this" ] }
          }
        },
        "in": { "$gte": [ { "$strLenCP": "$$this" }, &lt;size of array&gt;] }
      }
    }
  }
}
</pre>



<p></p>



<p id="block-5a4646dd-384f-4d1f-acaa-faefc9a3a739">Where &lt;YourFieldName&gt; is the Mongo Field Name whose value length needs to be calculated.  </p>



<p></p>



<p></p>



<h3 class="wp-block-heading" id="aioseo-mongodb-string-field-value-length-greater-than-query">MongoDB nested array string field value greater than query &gt;</h3>



<p></p>



<p>Below is the MongoDB string field value length greater than the query.</p>



<p><strong><em>Example</em></strong></p>



<p></p>



<p>In the below query, we get records where the field exists and the field length is <em><strong>greater than 5</strong></em> characters in size.</p>



<p></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="730" src="https://www.thecodebuzz.com/wp-content/uploads/2023/01/MongoDB-nested-array-field-value-length-query-less-than-1024x730.jpg" alt="mongodb update field with another field value " class="wp-image-25961" srcset="https://thecodebuzz.com/wp-content/uploads/2023/01/MongoDB-nested-array-field-value-length-query-less-than-1024x730.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2023/01/MongoDB-nested-array-field-value-length-query-less-than-300x214.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2023/01/MongoDB-nested-array-field-value-length-query-less-than-768x547.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2023/01/MongoDB-nested-array-field-value-length-query-less-than-729x520.jpg 729w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<h3 class="wp-block-heading" id="aioseo-mongodb-string-field-value-length-less-than-query">MongoDB nested Array field string value length less than query &lt;</h3>



<p></p>



<p>Below is the mongo Shell query for less than dates.</p>



<p></p>



<p><strong><em>Query Pattern</em></strong></p>



<p></p>



<p>Replace in the above query,</p>



<p></p>



<pre id="block-fbc452bd-ec31-4685-8b79-db63c13f0bcc" class="wp-block-preformatted has-medium-font-size"> "in": { "$lte": [ { "$strLenCP": "$$this" }, &lt;size of array&gt;] }</pre>



<p> </p>



<h3 class="wp-block-heading" id="aioseo-mongodb-string-field-value-length-equal-to-length">MongoDB nested Array field string value length Equal to length =</h3>



<p></p>



<p></p>



<p>Below is the mongo Shell query for equal to length query.</p>



<p></p>



<p><strong><em>Query Pattern</em></strong></p>



<p></p>



<p>Replace in the above query,</p>



<p></p>



<pre class="wp-block-preformatted"> "in": { "$eq": [ { "$strLenCP": "$$this" }, &lt;size of array&gt;] }</pre>



<p></p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-using-regex">Using Regex &#8211; MongoDB nested array string field value length query</h2>



<p></p>



<p>For more details on this approach please visit: </p>



<ul class="wp-block-list">
<li><a href="https://www.thecodebuzz.com/regex-mongodb-array-string-field-value-length-greater-than-less-than/" title="Using Regex – MongoDB array string field value length query"><strong>Using Regex – MongoDB array string field value length query</strong></a></li>
</ul>



<p></p>



<p></p>



<div class="wp-block-comments">
<p></p>



<p style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size"></p>



<p style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size"></p>



<p class="has-medium-font-size"><strong>Happy Coding </strong>!!</p>



<p></p>
</div>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p>



<p></p><p>The post <a href="https://thecodebuzz.com/mongodb-nested-array-string-field-value-length-query/">MongoDB nested array string field value length query</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/mongodb-nested-array-string-field-value-length-query/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>MongoDB Export top N records</title>
		<link>https://thecodebuzz.com/mongodb-export-top-n-records/</link>
					<comments>https://thecodebuzz.com/mongodb-export-top-n-records/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 21 Jan 2023 00:09:46 +0000</pubDate>
				<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[MongoDB Export top 10 records]]></category>
		<category><![CDATA[MongoDB Export top 100 records]]></category>
		<category><![CDATA[MongoDB Export top N records]]></category>
		<guid isPermaLink="false">https://www.thecodebuzz.com/?p=25933</guid>

					<description><![CDATA[<p>MongoDB Export Top N records Today in this article, we shall see how to perform MongoDB export top n records as CSV or JSON using available tools like Mongo Atlas UI and CLI tools. Today in this article, we will cover below aspects, We shall see how to export the MongoDB collection as CSV or [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/mongodb-export-top-n-records/">MongoDB Export top N records</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading" id="aioseo-mongodb-export-top-n-records">MongoDB Export Top N records</h1>



<figure class="wp-block-image size-large"><a href="https://www.thecodebuzz.com/mongodb-export-data-collections-array-fields-csv-json/" target="_blank" rel="noopener"><img loading="lazy" decoding="async" width="1024" height="292" src="https://www.thecodebuzz.com/wp-content/uploads/2021/08/How-to-export-mongodb-array-fields-to-CSV-1024x292.jpg" alt="Mongo - Export collection as CSV or JSON" class="wp-image-17695" srcset="https://thecodebuzz.com/wp-content/uploads/2021/08/How-to-export-mongodb-array-fields-to-CSV-1024x292.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/08/How-to-export-mongodb-array-fields-to-CSV-300x86.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/08/How-to-export-mongodb-array-fields-to-CSV-768x219.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/08/How-to-export-mongodb-array-fields-to-CSV-1536x438.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2021/08/How-to-export-mongodb-array-fields-to-CSV-785x224.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2021/08/How-to-export-mongodb-array-fields-to-CSV.jpg 1633w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></figure>



<p>Today in this article, we shall see how to perform MongoDB export top n records as CSV or JSON using available tools like Mongo Atlas UI and CLI tools.</p>



<p></p>



<p>Today in this article, we will cover below aspects,</p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-mongocompass-ui-export-documents-as-csv-or-json">MongoCompass Atlas UI- export documents</a><ul><li><a href="#aioseo-step1-open-the-collection-and-click-on-the-export-collection-icon-as-shown-below">Open the collection and click on the Export Collection icon</a></li></ul></li><li><a href="#aioseo-select-top-100-records-from-mongo-collection">Select the Top 100 records from Mongo Collection</a></li><li><a href="#aioseo-mongoshell-query">MongoShell Query</a></li><li><a href="#aioseo-using-cli-tool-mongoexport-to-export-the-data-as-csv-or-json">Using the CLI tool mongoexport to export the data as CSV or JSON</a></li></ul></div>



<p></p>



<p>We shall see how to export the MongoDB collection as CSV or JSON using Compass UI and <strong><em>mongoexport </em></strong>utility tools available.</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-mongocompass-ui-export-documents-as-csv-or-json"><strong>MongoCompass Atlas UI- export documents</strong></h2>



<p></p>



<p>If you are using MongoCompass Atlas UI or Robo Mongo client, both have rich UI features which let you export documents as CSV or JSON as required.</p>



<p></p>



<p><strong>Step to export the document or collection as CSV</strong></p>



<p></p>



<h3 class="wp-block-heading" id="aioseo-step1-open-the-collection-and-click-on-the-export-collection-icon-as-shown-below">Open the collection and click on the Export Collection icon</h3>



<p></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="318" src="https://www.thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-and-JSON-1-1024x318.jpg" alt="" class="wp-image-17693" srcset="https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-and-JSON-1-1024x318.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-and-JSON-1-300x93.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-and-JSON-1-768x238.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-and-JSON-1-1536x477.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-and-JSON-1-785x244.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-and-JSON-1.jpg 2017w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p>Select an option to <a href="https://www.thecodebuzz.com/mongodb-export-data-collections-array-fields-csv-json/">export the full collection</a> or export using a filter query.  you can select only fields of your choice.</p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-CSV-or-JSON-1024x567.jpg" alt="" class="wp-image-17688" width="491" height="271" srcset="https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-CSV-or-JSON-1024x567.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-CSV-or-JSON-300x166.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-CSV-or-JSON-768x426.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-CSV-or-JSON-785x435.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-CSV-or-JSON.jpg 1218w" sizes="auto, (max-width: 491px) 100vw, 491px" /></figure>



<p></p>



<p>The above query will <a href="https://www.thecodebuzz.com/mongodb-export-data-collections-array-fields-csv-json/">export the entire collection</a> into <strong>JSON </strong>or <strong>CSV</strong>.</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-select-top-100-records-from-mongo-collection">Select the Top 100 records from Mongo Collection</h2>



<p></p>



<p>Let&#8217;s select the Top N records from Mongo Collection.</p>



<p></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="268" src="https://www.thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-100-records-1024x268.jpg" alt="Select the Top 100 records from Mongo Collection" class="wp-image-25934" srcset="https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-100-records-1024x268.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-100-records-300x78.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-100-records-768x201.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-100-records-785x205.jpg 785w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p>Above we are exporting the top 100 records without any Filter or Sort logic.</p>



<p></p>



<p>Here, we will be able to export the top 100 records in JSON or CSV format easily </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="463" src="https://www.thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-n-records-using-limit-1024x463.jpg" alt="" class="wp-image-25935" srcset="https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-n-records-using-limit-1024x463.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-n-records-using-limit-300x136.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-n-records-using-limit-768x347.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-n-records-using-limit-785x355.jpg 785w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Please select the options JSON or CSV as required. You need to provide an output file path. Next, click on the <strong>EXPORT </strong>button.</p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-or-JSON-1024x576.jpg" alt="" class="wp-image-17678" width="493" height="277" srcset="https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-or-JSON-1024x576.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-or-JSON-300x169.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-or-JSON-768x432.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-or-JSON-785x442.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-or-JSON.jpg 1237w" sizes="auto, (max-width: 493px) 100vw, 493px" /></figure>



<p></p>



<p>After successful export, you shall see the top 100 records exported CSV file with the required details.</p>



<p></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="355" src="https://www.thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-1024x355.jpg" alt="export the Top 100 records from Mongo Collection" class="wp-image-17690" srcset="https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-1024x355.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-300x104.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-768x267.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-1536x533.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-2048x711.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-785x272.jpg 785w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-mongoshell-query"><strong>MongoShell Query </strong></h2>



<p></p>



<p>Below sample query gives the output of the top 100 records without any filters. </p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">db.Books.Find({}).limit(100)</pre>



<p></p>



<p>The above query can be extended with additional filters as required. </p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-using-cli-tool-mongoexport-to-export-the-data-as-csv-or-json"><strong>Using the CLI tool mongoexport to export the data as CSV or JSON</strong></h2>



<p></p>



<p>Using the CLI tool <strong>mongoexport </strong>to export the data as CSV or JSON</p>



<p></p>



<p id="block-3331047b-fb8d-4dbb-be67-70197834852c"><strong>mongoexport </strong>utility can be found at the below location,</p>



<p></p>



<pre class="wp-block-preformatted"><strong><em>C:Program FilesMongoDBServer4.0bin</em></strong></pre>



<p></p>



<p><strong>Command</strong></p>



<p></p>



<pre id="block-21b4b4d9-a312-4672-a4fa-1f3703ddfb84" class="wp-block-preformatted has-medium-font-size">mongoexport.exe --uri="your mongodb uri" --collection="your collection name" --type=csv --fields=fields1,field2,field3 --out = "Output file name" -q= { Your query}</pre>



<p></p>



<p><strong><em>Example</em></strong></p>



<p></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="555" src="https://www.thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-n-records-limit-1-1024x555.jpg" alt="" class="wp-image-25939" srcset="https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-n-records-limit-1-1024x555.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-n-records-limit-1-300x163.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-n-records-limit-1-768x416.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-n-records-limit-1-1536x832.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-n-records-limit-1-2048x1110.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2023/01/mongodb-export-top-n-records-limit-1-785x425.jpg 785w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p>Generated CSV file looks as below,</p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-file-1024x478.jpg" alt="" class="wp-image-17691" width="707" height="330" srcset="https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-file-1024x478.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-file-300x140.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-file-768x359.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-file-1536x717.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-file-2048x957.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2021/08/export-mongodb-as-CSV-file-785x367.jpg 785w" sizes="auto, (max-width: 707px) 100vw, 707px" /></figure>



<p></p>



<p><strong><em>Reference :</em></strong> </p>



<p></p>



<ul class="wp-block-list">
<li><a href="https://www.thecodebuzz.com/mongodb-distributed-transaction-acid-csharp-driver-aspnetcore/" target="_blank" rel="noreferrer noopener" title="MongoDB Distributed Transaction with C# .NET – Guidelines"><strong><em>MongoDB Distributed Transaction – Guidelines</em></strong></a></li>
</ul>



<p></p>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p><p>The post <a href="https://thecodebuzz.com/mongodb-export-top-n-records/">MongoDB Export top N records</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/mongodb-export-top-n-records/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Find MongoDB records where array field is not empty- $ne</title>
		<link>https://thecodebuzz.com/find-mongodb-records-where-array-field-is-not-empty-ne/</link>
					<comments>https://thecodebuzz.com/find-mongodb-records-where-array-field-is-not-empty-ne/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 01 Nov 2022 16:58:00 +0000</pubDate>
				<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[mongodb aggregation check if array is empty]]></category>
		<category><![CDATA[mongodb array contains]]></category>
		<category><![CDATA[mongodb array size greater than]]></category>
		<category><![CDATA[mongodb check if value exists in array]]></category>
		<category><![CDATA[mongodb find not empty object]]></category>
		<category><![CDATA[mongodb query not empty string]]></category>
		<category><![CDATA[mongodb set empty array]]></category>
		<guid isPermaLink="false">https://www.thecodebuzz.com/?p=24581</guid>

					<description><![CDATA[<p>Find MongoDB records where array field is not empty Today in this article we will see how to Find MongoDB records where array field is not empty or empty. Recently I was trying to find all the records where the array field has more than documents. After the initial trivial, I found there is no [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/find-mongodb-records-where-array-field-is-not-empty-ne/">Find MongoDB records where array field is not empty- $ne</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading">Find MongoDB records where array field is not empty</h1>



<figure class="wp-block-image is-resized"><a href="https://www.thecodebuzz.com/mongodb-query-for-documents-array-size-is-greater-than-mongoshell-cli-node-js" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/07/MongoDB-Query-documents-array-size-is-greater-than-1-1024x304.jpg" alt="Find MongoDB records where array field is not empty- $ne" class="wp-image-22722" width="810" height="240" title="MongoDB-Query-documents-array-size-is-greater-than-1 | TheCodeBuzz" srcset="https://thecodebuzz.com/wp-content/uploads/2022/07/MongoDB-Query-documents-array-size-is-greater-than-1-1024x304.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/07/MongoDB-Query-documents-array-size-is-greater-than-1-300x89.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/07/MongoDB-Query-documents-array-size-is-greater-than-1-768x228.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/07/MongoDB-Query-documents-array-size-is-greater-than-1-1536x456.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2022/07/MongoDB-Query-documents-array-size-is-greater-than-1-785x233.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2022/07/MongoDB-Query-documents-array-size-is-greater-than-1.jpg 1570w" sizes="auto, (max-width: 810px) 100vw, 810px" /></a></figure>



<p>Today in this article we will see how to Find MongoDB records where array field is not empty or empty.</p>



<p></p>



<p>Recently I was trying to find all the records where the array field has more than documents. After the initial trivial, I found there is no direct query but was able to find a query that helped me address this requirement easily.</p>



<p></p>



<p>Below is a sample JSON where array order is defined as an array type.</p>



<p></p>



<p></p>



<p>Array&nbsp;<strong><em>order&nbsp;</em></strong>has 1 to 3 items in the collection.</p>



<p>We will build a query to find all the items where the array size is greater than 1.</p>



<p></p>



<h2 class="wp-block-heading">Find MongoDB records where array field is not empty using $ne</h2>



<p></p>



<h3 class="wp-block-heading"><strong>Query</strong></h3>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">{&lt;array field&gt;: {$type:'array', $ne: [] }}</pre>



<p></p>



<div data-schema-only="false" class="wp-block-aioseo-faq"><h3 class="aioseo-faq-block-question">What is $ne</h3><div class="aioseo-faq-block-answer">
<p>$<em>ne</em>&nbsp;is a comparison operator which lets you select the documents where the value of the field is not equal to the specified value. </p>



<p></p>
</div></div>



<p></p>



<p></p>



<p><strong>Example</strong></p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">{order: {$type: 'array', $ne: []}}</pre>



<p></p>



<p>The above query verifies for the <strong><em>array &#8220;order&#8221; field is not empty.</em></strong> </p>



<p></p>



<p>The above query also means to return all the MongoDB documents where the array has at least 1 element existing.</p>



<p></p>



<p>In our above example, The below query gives us results for array size&nbsp;<strong><em>1 or 2</em></strong> or more&nbsp;as below,</p>



<p></p>



<figure class="wp-block-image"><a href="https://www.thecodebuzz.com/mongodb-query-for-documents-array-size-is-greater-than-mongoshell-cli-node-js" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="702" height="686" src="https://www.thecodebuzz.com/wp-content/uploads/2022/07/MongoDB-Query-for-documents-array-size-is-greater-than-1-2.jpg" alt="Find MongoDB records where array field is not empty- $ne" class="wp-image-22717" title="MongoDB-Query-for-documents-array-size-is-greater-than-1-2 | TheCodeBuzz" srcset="https://thecodebuzz.com/wp-content/uploads/2022/07/MongoDB-Query-for-documents-array-size-is-greater-than-1-2.jpg 702w, https://thecodebuzz.com/wp-content/uploads/2022/07/MongoDB-Query-for-documents-array-size-is-greater-than-1-2-300x293.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/07/MongoDB-Query-for-documents-array-size-is-greater-than-1-2-532x520.jpg 532w" sizes="auto, (max-width: 702px) 100vw, 702px" /></a></figure>



<p id="aioseo-approach-ii--mongodb-query-for-documents-array-size-is-greater-than-0-or-1-or-2"></p>



<h2 class="wp-block-heading">Find MongoDB records where array field is empty using $eq</h2>



<p></p>



<h3 class="wp-block-heading"><strong>Query</strong></h3>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">{&lt;array field&gt;: {$type:'array', $eq: [] }}</pre>



<p></p>



<div data-schema-only="false" class="wp-block-aioseo-faq"><h3 class="aioseo-faq-block-question">What is $eq</h3><div class="aioseo-faq-block-answer">
<p>$<em>eq</em> is a comparison operator which lets you select the documents where the value of the field is equal to the specified value. </p>



<p></p>
</div></div>



<p></p>



<p><strong>Example</strong></p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">{order: {$type: 'array', $eq: []}}

</pre>



<p>Alternatively, you can also use the below query to find all the documents where the array field is not empty.</p>



<p></p>



<pre class="wp-block-preformatted">{'order.0': {$exists: true}}</pre>



<p></p>



<p>The above query will return all the records where the&nbsp;<strong><em>array size is greater than or equal to 1</em></strong></p>



<p></p>



<p></p>



<p style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size"></p>



<p style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size"></p>



<p class="has-medium-font-size"><strong>Happy Coding </strong>!!</p>



<p></p>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p><p>The post <a href="https://thecodebuzz.com/find-mongodb-records-where-array-field-is-not-empty-ne/">Find MongoDB records where array field is not empty- $ne</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/find-mongodb-records-where-array-field-is-not-empty-ne/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
