avatarNaina Chaturvedi

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

26238

Abstract

re></div><p id="5084">JSONB Functions: PostgreSQL provides a rich set of functions for working with JSONB data type, which allows storing and querying JSON documents.</p><div id="0f4a"><pre>-- <span class="hljs-title class_">Extract</span> value <span class="hljs-keyword">from</span> <span class="hljs-title class_">JSON</span> <span class="hljs-variable language_">document</span> <span class="hljs-variable constant_">SELECT</span> <span class="hljs-title function_">jsonb_extract_path</span>(<span class="hljs-string">'{"name": "John", "age": 30}'</span>, <span class="hljs-string">'name'</span>);</pre></div><div id="7814"><pre><span class="hljs-comment">-- Check if JSON document contains a specific key</span> <span class="hljs-keyword">SELECT</span> <span class="hljs-string">'{"name": "John", "age": 30}'</span>::jsonb ? <span class="hljs-string">'age'</span>;</pre></div><div id="94a3"><pre><span class="hljs-comment">-- Modify JSON document by adding or updating a key-value pair</span> <span class="hljs-keyword">SELECT</span> jsonb_set(<span class="hljs-string">'{"name": "John"}'</span>, <span class="hljs-string">'{age}'</span>, <span class="hljs-string">'30'</span>::jsonb, <span class="hljs-literal">true</span>);</pre></div><p id="2675">Window Functions: Window functions perform calculations across a set of rows that are related to the current row. They allow you to perform complex aggregations and calculations without the need for subqueries or joins.</p><div id="5f95"><pre><span class="hljs-comment">-- Calculate the average salary for each department, along with the total and rank</span> <span class="hljs-keyword">SELECT</span> department, <span class="hljs-built_in">AVG</span>(salary) <span class="hljs-keyword">OVER</span> (<span class="hljs-keyword">PARTITION</span> <span class="hljs-keyword">BY</span> department) <span class="hljs-keyword">AS</span> avg_salary, <span class="hljs-built_in">SUM</span>(salary) <span class="hljs-keyword">OVER</span> (<span class="hljs-keyword">PARTITION</span> <span class="hljs-keyword">BY</span> department) <span class="hljs-keyword">AS</span> total_salary, <span class="hljs-built_in">RANK</span>() <span class="hljs-keyword">OVER</span> (<span class="hljs-keyword">PARTITION</span> <span class="hljs-keyword">BY</span> department <span class="hljs-keyword">ORDER</span> <span class="hljs-keyword">BY</span> salary <span class="hljs-keyword">DESC</span>) <span class="hljs-keyword">AS</span> rank <span class="hljs-keyword">FROM</span> employees;</pre></div><p id="3414">Common Table Expressions (CTEs): CTEs are temporary result sets that can be used within a query. They allow you to break down complex queries into more manageable and readable parts.</p><div id="7b30"><pre>-- Use CTE <span class="hljs-keyword">to</span> calculate the total sales <span class="hljs-keyword">for</span> <span class="hljs-keyword">each</span> product category <span class="hljs-keyword">WITH</span> category_sales <span class="hljs-keyword">AS</span> ( <span class="hljs-keyword">SELECT</span> category, SUM(sales) <span class="hljs-keyword">AS</span> total_sales <span class="hljs-keyword">FROM</span> sales <span class="hljs-keyword">GROUP</span> <span class="hljs-keyword">BY</span> category ) <span class="hljs-keyword">SELECT</span> category, total_sales <span class="hljs-keyword">FROM</span> category_sales <span class="hljs-keyword">ORDER</span> <span class="hljs-keyword">BY</span> total_sales DESC;</pre></div><p id="eac3">Full-Text Search Functions: PostgreSQL provides full-text search capabilities, allowing you to perform advanced text search operations.</p><div id="ee43"><pre><span class="hljs-comment">-- Search for documents containing specific keywords</span> <span class="hljs-keyword">SELECT</span> <span class="hljs-operator">*</span> <span class="hljs-keyword">FROM</span> documents <span class="hljs-keyword">WHERE</span> to_tsvector(<span class="hljs-string">'english'</span>, content) @@ to_tsquery(<span class="hljs-string">'english'</span>, <span class="hljs-string">'search keywords'</span>);</pre></div><p id="ca88">In this post we will go in depth and cover the most important constructs of PostgreSQL.</p><ul><li>Access the PostgreSQL server</li><li>Connect to a database</li><li>List database, views and tables</li><li>Create, Delete and Alter databases</li><li>Views and Indexes</li><li>Query data from tables</li><li>SET operations</li><li>Insert, Delete and Update</li><li>Performance and Statistics</li></ul><p id="e3de">Implementation —</p><div id="bcaa"><pre>import psycopg2

<span class="hljs-comment"># Access the PostgreSQL server</span> conn = psycopg2.connect( host=<span class="hljs-string">"your_host"</span>, database=<span class="hljs-string">"your_database"</span>, user=<span class="hljs-string">"your_username"</span>, password=<span class="hljs-string">"your_password"</span> )

<span class="hljs-comment"># Connect to a database</span> cur = conn.cursor() cur.execute(<span class="hljs-string">"SELECT version();"</span>) <span class="hljs-keyword">print</span>(cur.fetchone()[<span class="hljs-number">0</span>])

<span class="hljs-comment"># List databases</span> cur.execute(<span class="hljs-string">"SELECT datname FROM pg_database;"</span>) databases = cur.fetchall() <span class="hljs-keyword">print</span>(<span class="hljs-string">"Databases:"</span>) <span class="hljs-keyword">for</span> db in databases: <span class="hljs-keyword">print</span>(db[<span class="hljs-number">0</span>])

<span class="hljs-comment"># List views</span> cur.execute(<span class="hljs-string">"SELECT table_name FROM information_schema.views WHERE table_schema = 'public';"</span>) views = cur.fetchall() <span class="hljs-keyword">print</span>(<span class="hljs-string">"Views:"</span>) <span class="hljs-keyword">for</span> view in views: <span class="hljs-keyword">print</span>(view[<span class="hljs-number">0</span>])

<span class="hljs-comment"># List tables</span> cur.execute(<span class="hljs-string">"SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_type = 'BASE TABLE';"</span>) tables = cur.fetchall() <span class="hljs-keyword">print</span>(<span class="hljs-string">"Tables:"</span>) <span class="hljs-keyword">for</span> table in tables: <span class="hljs-keyword">print</span>(table[<span class="hljs-number">0</span>])

<span class="hljs-comment"># Create a database</span> cur.execute(<span class="hljs-string">"CREATE DATABASE new_database;"</span>) conn.commit() <span class="hljs-keyword">print</span>(<span class="hljs-string">"New database created."</span>)

<span class="hljs-comment"># Delete a database</span> cur.execute(<span class="hljs-string">"DROP DATABASE existing_database;"</span>) conn.commit() <span class="hljs-keyword">print</span>(<span class="hljs-string">"Existing database deleted."</span>)

<span class="hljs-comment"># Alter a database</span> cur.execute(<span class="hljs-string">"ALTER DATABASE existing_database RENAME TO new_name;"</span>) conn.commit() <span class="hljs-keyword">print</span>(<span class="hljs-string">"Database name altered."</span>)

<span class="hljs-comment"># Create a view</span> cur.execute(<span class="hljs-string">"CREATE VIEW new_view AS SELECT * FROM table_name;"</span>) conn.commit() <span class="hljs-keyword">print</span>(<span class="hljs-string">"New view created."</span>)

<span class="hljs-comment"># Create an index</span> cur.execute(<span class="hljs-string">"CREATE INDEX idx_column ON table_name (column_name);"</span>) conn.commit() <span class="hljs-keyword">print</span>(<span class="hljs-string">"Index created."</span>)

<span class="hljs-comment"># Query data from a table</span> cur.execute(<span class="hljs-string">"SELECT * FROM table_name WHERE condition;"</span>) data = cur.fetchall() <span class="hljs-keyword">for</span> row in data: <span class="hljs-keyword">print</span>(row)

<span class="hljs-comment"># Perform SET operations</span> cur.execute(<span class="hljs-string">"SELECT * FROM table1 UNION SELECT * FROM table2;"</span>) union_result = cur.fetchall() <span class="hljs-keyword">print</span>(<span class="hljs-string">"Union result:"</span>) <span class="hljs-keyword">for</span> row in union_result: <span class="hljs-keyword">print</span>(row)

<span class="hljs-comment"># Insert data into a table</span> cur.execute(<span class="hljs-string">"INSERT INTO table_name (column1, column2) VALUES (%s, %s);"</span>, (value1, value2)) conn.commit() <span class="hljs-keyword">print</span>(<span class="hljs-string">"Data inserted."</span>)

<span class="hljs-comment"># Delete data from a table</span> cur.execute(<span class="hljs-string">"DELETE FROM table_name WHERE condition;"</span>) conn.commit() <span class="hljs-keyword">print</span>(<span class="hljs-string">"Data deleted."</span>)

<span class="hljs-comment"># Update data in a table</span> cur.execute(<span class="hljs-string">"UPDATE table_name SET column1 = %s WHERE condition;"</span>, (new_value,)) conn.commit() <span class="hljs-keyword">print</span>(<span class="hljs-string">"Data updated."</span>)

<span class="hljs-comment"># Get performance statistics</span> cur.execute(<span class="hljs-string">"EXPLAIN ANALYZE SELECT * FROM table_name;"</span>) performance_stats = cur.fetchall() <span class="hljs-keyword">for</span> <span class="hljs-keyword">stat</span> in performance_stats: <span class="hljs-keyword">print</span>(<span class="hljs-keyword">stat</span>[<span class="hljs-number">0</span>])

<span class="hljs-comment"># Close the cursor and connection</span> cur.close() conn.close()</pre></div><p id="a692">Let’s get started with important constructs.</p><h2 id="8a33">Access the PostgreSQL server</h2><p id="7625">To access the server from psql</p><p id="b355">Syntax —</p><blockquote id="3df6"><p>psql -U [user_name];</p></blockquote><h2 id="6ee2">Connect to a database and check version</h2><ol><li>To connect to a database —</li></ol><p id="45aa">Syntax —</p><blockquote id="814a"><p>\c database_name</p></blockquote><p id="6582">2. Check version</p><p id="176d">Syntax —</p><blockquote id="ffda"><p>psql -V</p></blockquote><h2 id="9cdc">List database, views and tables</h2><ol><li>List database</li></ol><p id="2ec1">Syntax —</p><blockquote id="7960"><p>psql -l</p></blockquote><p id="2761">2. List views</p><p id="9561">Syntax —</p><blockquote id="c392"><p>\dv</p></blockquote><p id="cae8">3. List tables</p><p id="e0a7">Syntax —</p><blockquote id="7975"><p>\dt</p></blockquote><h2 id="ac2a">Create, Delete and Alter table in the database</h2><ol><li>Create new table Database</li></ol><p id="a7e5">Syntax —</p><blockquote id="d2a0"><p>CREATE TABLE table_name</p></blockquote><blockquote id="9950"><p>( primarykey SERIAL PRIMARY KEY, c1 type(size) NOT NULL, … );</p></blockquote><p id="5f1b">2. Delete Table</p><p id="2aed">Syntax —</p><blockquote id="6ebb"><p>DROP TABLE table_name CASCADE;</p></blockquote><p id="6f4b">3. Alter Table</p><p id="741c">Syntax —</p><blockquote id="8c77"><p>ALTER TABLE table_name DROP COLUMN column_name;</p></blockquote><h2 id="1b2e">Views , triggers and Indexes</h2><p id="3053">1.Create a new view</p><p id="3dfd">Syntax —</p><blockquote id="0b49"><p>CREATE VIEW view_name</p></blockquote><blockquote id="7a9a"><p>As SELECT_STATEMENT;</p></blockquote><p id="6863">2. Create or replace a view</p><p id="2cc2">Syntax —</p><blockquote id="80c0"><p>CREATE OR REPLACE VIEW view_name</p></blockquote><blockquote id="3f55"><p>As SELECT_STATEMENT;</p></blockquote><p id="11e5">3.Drop a view</p><p id="9bd1">Syntax —</p><blockquote id="a72c"><p>DROP VIEW view_name;</p></blockquote><p id="effb">4. Rename a view</p><p id="a440">Syntax —</p><blockquote id="5571"><p>RENAME TABLE view_name</p></blockquote><blockquote id="f4dd"><p>TO new_name;</p></blockquote><p id="041c">5. Show views</p><p id="0365">Syntax —</p><blockquote id="ec76"><p>SHOW FULL TABLES</p></blockquote><blockquote id="31e3"><p>FROM database_name</p></blockquote><blockquote id="828f"><p>WHERE tabletype = ‘VIEW’;</p></blockquote><p id="19c6"><b>Triggers</b></p><ol><li>Create a new trigger</li></ol><p id="1f86">Syntax —</p><blockquote id="6ea9"><p>CREATE TRIGGER trigger_name</p></blockquote><blockquote id="820b"><p>BEFORE/AFTER</p></blockquote><blockquote id="bcbe"><p>SQL Statement (INSERT/UPDATE/DELETE/ALTER)</p></blockquote><blockquote id="4b73"><p>ON table_name</p></blockquote><blockquote id="133c"><p>FOR EACH ROW SET operation;</p></blockquote><p id="f2f6">2. Drop a trigger</p><p id="dfee">Syntax —</p><blockquote id="3d57"><p>DROP Trigger trigger_name;</p></blockquote><p id="ba31">3. Show triggers</p><p id="a86b">Syntax —</p><blockquote id="7c83"><p>SHOW Triggers FROM database_name</p></blockquote><blockquote id="899e"><p>WHERE condition</p></blockquote><p id="4809"><b>Indexes</b></p><p id="ee30">To create Indexes —</p><blockquote id="869d"><p><i>CREATE INDEX index_name</i></p></blockquote><blockquote id="469f"><p><i>ON table (column_1, column_2, …column_n)</i></p></blockquote><h2 id="a3a9">Query data from tables</h2><ol><li>Select</li></ol><p id="5589">Syntax —</p><blockquote id="e84c"><p>SELECT t1, t2, … FROM table_name;</p></blockquote><p id="4905">2. Search using like</p><p id="12c9">Syntax —</p><blockquote id="35e6"><p>SELECT * FROM table_name WHERE column_name LIKE ‘%ny%’</p></blockquote><blockquote id="4559"><p>SELECT * FROM table_name WHERE column_name LIKE ‘_ewyork’</p></blockquote><blockquote id="9752"><p>SELECT * FROM table_name WHERE column_name LIKE ‘_e_yo_k’</p></blockquote><blockquote id="1463"><p>SELECT * FROM table_name WHERE column_name LIKE ‘[n-y]%’</p></blockquote><blockquote id="09a2"><p>SELECT * FROM table_name WHERE column_name LIKE ‘[adf]%’</p></blockquote><p id="8081">3. Distinct</p><p id="c9fa">Syntax —</p><blockquote id="df39"><p>SELECT DISTINCT (column_name) FROM table_name;</p></blockquote><p id="67c7">4. Joins</p><p id="a93c">Syntax —</p><blockquote id="7642"><p>SELECT column_names</p></blockquote><blockquote id="871a"><p>FROM table1 JOIN table2</p></blockquote><blockquote id="3b6f"><p>ON column_name1 = column_name2</p></blockquote><blockquote id="d1f8"><p>WHERE condition</p></blockquote><p id="fdf3">5. Group by</p><p id="a53f">Syntax —</p><blockquote id="2ed4"><p>SELECT column_names</p></blockquote><blockquote id="4f68"><p>FROM table</p></blockquote><blockquote id="fbbe"><p>WHERE condition</p></blockquote><blockquote id="45fd"><p>GROUP BY column_names</p></blockquote><p id="0143">6. Order by</p><p id="e0b4">Syntax —</p><blockquote id="b41e"><p>SELECT column_names</p></blockquote><blockquote id="1c2a"><p>FROM table</p></blockquote><blockquote id="f936"><p>WHERE condition</p></blockquote><blockquote id="ced8"><p>ORDER BY column_names</p></blockquote><p id="b0ce">7. Filter Data</p><p id="3e35">Syntax —</p><blockquote id="8d4c"><p>Select t1</p></blockquote><blockquote id="018b"><p>from table_name</p></blockquote><blockquote id="26ac"><p>Where t1 > 4</p></blockquote><p id="b28c">Using other comparison Operator —</p><blockquote id="d614"><p>Select t1</p></blockquote><blockquote id="4b53"><p>from table_name</p></blockquote><blockquote id="fd25"><p>Where t1 != ‘string’</p></blockquote><blockquote id="cec8"><p>Select t1,t2</p></blockquote><blockquote id="d3d9"><p>from table_name</p></blockquote><blockquote id="bccb"><p>Where t1 == 17 AND t2 == ‘string’</p></blockquote><h2 id="18bc">SET operations</h2><p id="90e7">For UNION</p><p id="8f4f">Syntax —</p><blockquote id="c947"><p>Select t1, t2 FROM table1 UNION Select r1, r2 FROM table2</p></blockquote><p id="1240">INTERSECT</p><p id="93a5">Syntax —</p><blockquote id="d092"><p>Select t1, t2</p></blockquote><blockquote id="2a9f"><p>FROM table_name</p></blockquote><blockquote id="b41f"><p>WHERE Condition</p></blockquote><blockquote id="ea09"><p><b>INTERSECT</b></p></blockquote><blockquote id="4a98"><p>Select r1, r2</p></blockquote><blockquote id="6d2e"><p>FROM table_name</p></blockquote><blockquote id="1ebc"><p>WHERE Condition</p></blockquote><p id="0a26">EXCEPT</p><p id="b3cf">Syntax —</p><blockquote id="4dc6"><p>Select t1, t2</p></blockquote><blockquote id="0ffe"><p>FROM table_name</p></blockquote><blockquote id="0d95"><p>WHERE Condition</p></blockquote><blockquote id="0477"><p><b>EXCEPT</b></p></blockquote><blockquote id="4855"><p>Select r1, r2</p></blockquote><blockquote id="8b24"><p>FROM table_name</p></blockquote><blockquote id="a33d"><p>WHERE Condition</p></blockquote><h2 id="3055">Insert, Delete and Update</h2><ol><li>Insert</li></ol><p id="41b7">Syntax —</p><blockquote id="ae21"><p>Insert into table_name ( column_1, column_2) values (values_1,values_2,…values_n);</p></blockquote><p id="47dd">2. Update</p><p id="7dca">Syntax —</p><blockquote id="9a93"><p>Update table_name SET Column_name = value where Condition;</p></blockquote><p id="97b4">3. Delete</p><p id="cc0e">Syntax —</p><blockquote id="73da"><p>Delete FROM table_name;</p></blockquote><h2 id="cb05">Create Roles and Change the Roles</h2><p id="23f2">Create Role</p><p id="f560">Syntax —</p><blockquote id="54ee"><p>CREATE ROLE role_name;</p></blockquote><p id="b948">Change the Role</p><p id="feaf">Syntax —</p><blockquote id="4dd0"><p>SET Role newrole_name;</p></blockquote><h2 id="ee7b">Performance and Statistics</h2><p id="5494">For statistics collection</p><p id="464a">Syntax —</p><blockquote id="fc94"><p>ANALYZE table_name;</p></blockquote><p id="da11">To show and execute query plan</p><p id="ddb8">Syntax —</p><blockquote id="4896"><p>EXPLAIN ANALYZE sql_query;</p></blockquote><p id="ee75">Snippet —</p><figure id="8f65"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*E0sJvw3_YWT_0I8fAORGvg.png"><figcaption></figcaption></figure><h1 id="fd08">MongoDB</h1><figure id="a12a"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*zIFicqF4jgOy6ueo.png"><figcaption>Pic credits : Quora</figcaption></figure><p id="94cf">MongoDB works by storing data in a document format, where each document is a collection of key-value pairs. These documents are stored in collections, which are similar to tables in a relational database.</p><p id="6aa5">Each document in a collection can have a unique structure, meaning that the fields in one document do not have to match the fields in another document within the same collection.</p><ul><li><i>When a client sends a request to MongoDB, the request is passed to the MongoDB server, which then performs the requested operation on the appropriate collection or document. The MongoDB server uses a storage engine to handle the underlying storage and retrieval of data. The default storage engine is called WiredTiger, but MongoDB also supports other storage engines such as MMAPv1 and RocksDB.</i></li><li><i>One of the key features of MongoDB is its ability to scale horizontally. This is achieved through a process called sharding, where data is split across multiple servers, called shards. Each shard is responsible for storing a portion of the data, and the MongoDB server uses a routing process to determine which shard a particular request should be sent to.</i></li><li><i>MongoDB also provides automatic failover capabilities, where if a primary server goes down, a secondary server is automatically promoted to primary to ensure high availability. Additionally, MongoDB has built-in support for replica sets, which are groups of servers that maintain a copy of the same data, providing additional redundancy and failover protection.</i></li></ul><p id="0d8b">Overall, MongoDB is designed to provide a flexible, high-performance, and highly available system for storing and querying large amounts of unstructured data.</p><p id="a457">Some important functions —</p><div id="407a"><pre><span class="hljs-type">Find</span>: <span class="hljs-type">The</span> find function <span class="hljs-keyword">is</span> used to query documents <span class="hljs-keyword">in</span> a collection based on specified criteria. <span class="hljs-comment">// Find documents in the "users" collection where the age is greater than 25</span> db.users.find({ age: { <span class="hljs-variable">gt</span>: <span class="hljs-number">25</span> } }); <span class="hljs-type">InsertOne</span>: <span class="hljs-type">The</span> insertOne function <span class="hljs-keyword">is</span> used to insert a single document into a collection. <span class="hljs-comment">// Insert a new document into the "users" collection</span> db.users.insertOne({ name: <span class="hljs-string">"John"</span>, age: <span class="hljs-number">30</span> }); <span class="hljs-type">UpdateOne</span>: <span class="hljs-type">The</span> updateOne function <span class="hljs-keyword">is</span> used to update a single document <span class="hljs-keyword">in</span> a collection. <span class="hljs-comment">// Update the document with name "John" in the "users" collection, set age to 35</span> db.users.updateOne({ name: <span class="hljs-string">"John"</span> }, { <span class="hljs-variable">set</span>: { age: <span class="hljs-number">35</span> } }); <span class="hljs-type">DeleteOne</span>: <span class="hljs-type">The</span> deleteOne function <span class="hljs-keyword">is</span> used to delete a single document from a collection. <span class="hljs-comment">// Delete the document with name "John" from the "users" collection</span> db.users.deleteOne({ name: <span class="hljs-string">"John"</span> }); <span class="hljs-type">Aggregate</span>: <span class="hljs-type">The</span> aggregate function <span class="hljs-keyword">is</span> used to perform advanced aggregation operations on a collection, such <span class="hljs-keyword">as</span> grouping, sorting, and calculating aggregate values. <span class="hljs-comment">// Calculate the average age of users in the "users" collection</span> db.users.aggregate([ { <span class="hljs-variable">group</span>: { _id: null, avgAge: { <span class="hljs-variable">avg</span>: <span class="hljs-string">"age"</span> } } } ]); <span class="hljs-variable">lookup</span>: <span class="hljs-type">The</span> <span class="hljs-variable">lookup</span> function <span class="hljs-keyword">is</span> used <span class="hljs-keyword">for</span> performing a left outer join between two collections and retrieving matched documents from the joined collection. <span class="hljs-comment">// Perform a left outer join between "orders" and "customers" collections</span> db.orders.aggregate([ { <span class="hljs-variable">lookup</span>: { from: <span class="hljs-string">"customers"</span>, localField: <span class="hljs-string">"customerId"</span>, foreignField: <span class="hljs-string">"_id"</span>, as: <span class="hljs-string">"customer"</span> } } ]); <span class="hljs-variable">group</span>: <span class="hljs-type">The</span> <span class="hljs-variable">group</span> function <span class="hljs-keyword">is</span> used <span class="hljs-keyword">for</span> grouping documents based on specified criteria and performing aggregate operations on grouped data. <span class="hljs-comment">// Group documents in the "orders" collection by customerId and calculate the total amount for each customer</span> db.orders.aggregate([ { <span class="hljs-variable">group</span>: { _id: <span class="hljs-string">"customerId"</span>, totalAmount: { <span class="hljs-variable">sum</span>: <span class="hljs-string">"amount"</span> } } } ]); <span class="hljs-variable">unwind</span>: <span class="hljs-type">The</span> <span class="hljs-variable">unwind</span> function <span class="hljs-keyword">is</span> used to deconstruct an array field and generate a new document <span class="hljs-keyword">for</span> <span class="hljs-keyword">each</span> element of the array. <span class="hljs-comment">// Unwind the "tags" array field in the "articles" collection</span> db.articles.aggregate([ { <span class="hljs-variable">unwind</span>: <span class="hljs-string">"tags"</span> } ]); <span class="hljs-variable">push</span>: <span class="hljs-type">The</span> <span class="hljs-variable">push</span> function <span class="hljs-keyword">is</span> used to add a value to an array field <span class="hljs-keyword">in</span> a document. <span class="hljs-comment">// Add a new tag to the "tags" array field in the document with _id "12345" in the "articles" collection</span> db.articles.updateOne( { _id: <span class="hljs-string">"12345"</span> }, { <span class="hljs-variable">push</span>: { tags: <span class="hljs-string">"newtag"</span> } } ); <span class="hljs-variable">regex</span>: <span class="hljs-type">The</span> <span class="hljs-variable">regex</span> function <span class="hljs-keyword">is</span> used <span class="hljs-keyword">for</span> performing regular expression<span class="hljs-operator">-</span>based pattern matching <span class="hljs-keyword">in</span> queries. <span class="hljs-comment">// Find documents in the "users" collection where the name starts with "J"</span> db.users.find({ name: { <span class="hljs-variable">regex</span>: <span class="hljs-string">"^J"</span> } });</pre></div><p id="c55f"><b>Here are some important MongoDB commands and examples:</b></p><ol><li><code><i>show dbs</i></code><i> - This command is used to display all the databases in the MongoDB server.</i></li><li><code><i>use <dbname></i></code><i> - This command is used to switch to a specific database. For example, <code>use testdb</code> will switch to the "testdb" database.</i></li><li><code><i>db.createCollection(name, options)</i></code><i> - This command is used to create a new collection in the current database. For example, <code>db.createCollection("employees")</code> will create a new collection named "employees" in the current database.</i></li><li><code><i>db.collection.insert(document)</i></code><i> - This command is used to insert a new document into a collection. For example, <code>db.employees.insert({name: "John Doe", age: 30, job: "Developer"})</code> will insert a new document into the "employees" collection.</i></li><li><code><i>db.collection.find()</i></code><i> - This command is used

Options

to find all documents in a collection. For example, <code>db.employees.find()</code> will return all documents in the "employees" collection.</i></li><li><code><i>db.collection.update(query, update, options)</i></code><i> - This command is used to update documents in a collection. For example, <code>db.employees.update({name: "John Doe"}, {$set: {age: 35}})</code> will update the document where the name is "John Doe" and set the age to 35.</i></li><li><code><i>db.collection.remove(query, justOne)</i></code><i> - This command is used to remove documents from a collection. For example, <code>db.employees.remove({name: "John Doe"})</code> will remove the document where the name is "John Doe" from the "employees" collection.</i></li><li><code><i>db.collection.drop()</i></code><i> - This command is used to delete a collection. For example, <code>db.employees.drop()</code> will delete the "employees" collection.</i></li><li><code><i>db.collection.count()</i></code><i> - This command is used to count the number of documents in a collection. For example, <code>db.employees.count()</code> will return the number of documents in the "employees" collection.</i></li><li><code><i>db.runCommand({command: value})</i></code><i> - This command is used to run any MongoDB command. For example, <code>db.runCommand({ping:1})</code> will return the status of the MongoDB server.</i></li></ol><p id="392d">Implementation —</p><div id="025e"><pre><span class="hljs-comment">// Connect to the MongoDB server</span> <span class="hljs-keyword">const</span> <span class="hljs-title class_">MongoClient</span> = <span class="hljs-built_in">require</span>(<span class="hljs-string">'mongodb'</span>).<span class="hljs-property">MongoClient</span>; <span class="hljs-keyword">const</span> url = <span class="hljs-string">'mongodb://localhost:27017'</span>; <span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> <span class="hljs-title class_">MongoClient</span>(url, { <span class="hljs-attr">useUnifiedTopology</span>: <span class="hljs-literal">true</span> });

<span class="hljs-keyword">async</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">main</span>(<span class="hljs-params"></span>) { <span class="hljs-keyword">try</span> { <span class="hljs-comment">// Connect to the server</span> <span class="hljs-keyword">await</span> client.<span class="hljs-title function_">connect</span>();

<span class="hljs-comment">// Show all databases</span>
<span class="hljs-keyword">const</span> databases = <span class="hljs-keyword">await</span> client.<span class="hljs-title function_">db</span>().<span class="hljs-title function_">admin</span>().<span class="hljs-title function_">listDatabases</span>();
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">'Databases:'</span>);
databases.<span class="hljs-property">databases</span>.<span class="hljs-title function_">forEach</span>(<span class="hljs-function">(<span class="hljs-params">db</span>) =&gt;</span> {
  <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(db.<span class="hljs-property">name</span>);
});

<span class="hljs-comment">// Switch to a specific database</span>
<span class="hljs-keyword">const</span> dbName = <span class="hljs-string">'testdb'</span>;
<span class="hljs-keyword">const</span> db = client.<span class="hljs-title function_">db</span>(dbName);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">`Switched to database: <span class="hljs-subst">${dbName}</span>`</span>);

<span class="hljs-comment">// Create a new collection</span>
<span class="hljs-keyword">const</span> collectionName = <span class="hljs-string">'employees'</span>;
<span class="hljs-keyword">await</span> db.<span class="hljs-title function_">createCollection</span>(collectionName);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">`Created collection: <span class="hljs-subst">${collectionName}</span>`</span>);

<span class="hljs-comment">// Insert a new document</span>
<span class="hljs-keyword">const</span> <span class="hljs-variable language_">document</span> = { <span class="hljs-attr">name</span>: <span class="hljs-string">'John Doe'</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">30</span>, <span class="hljs-attr">job</span>: <span class="hljs-string">'Developer'</span> };
<span class="hljs-keyword">await</span> db.<span class="hljs-title function_">collection</span>(collectionName).<span class="hljs-title function_">insertOne</span>(<span class="hljs-variable language_">document</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">'Inserted a new document into the collection'</span>);

<span class="hljs-comment">// Find all documents in the collection</span>
<span class="hljs-keyword">const</span> documents = <span class="hljs-keyword">await</span> db.<span class="hljs-title function_">collection</span>(collectionName).<span class="hljs-title function_">find</span>().<span class="hljs-title function_">toArray</span>();
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">'Documents:'</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(documents);

<span class="hljs-comment">// Update a document</span>
<span class="hljs-keyword">const</span> query = { <span class="hljs-attr">name</span>: <span class="hljs-string">'John Doe'</span> };
<span class="hljs-keyword">const</span> update = { <span class="hljs-attr">$set</span>: { <span class="hljs-attr">age</span>: <span class="hljs-number">35</span> } };
<span class="hljs-keyword">await</span> db.<span class="hljs-title function_">collection</span>(collectionName).<span class="hljs-title function_">updateOne</span>(query, update);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">'Updated document'</span>);

<span class="hljs-comment">// Remove a document</span>
<span class="hljs-keyword">await</span> db.<span class="hljs-title function_">collection</span>(collectionName).<span class="hljs-title function_">deleteOne</span>(query);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">'Removed document'</span>);

<span class="hljs-comment">// Delete the collection</span>
<span class="hljs-keyword">await</span> db.<span class="hljs-title function_">collection</span>(collectionName).<span class="hljs-title function_">drop</span>();
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">`Deleted collection: <span class="hljs-subst">${collectionName}</span>`</span>);

<span class="hljs-comment">// Count the number of documents in the collection</span>
<span class="hljs-keyword">const</span> count = <span class="hljs-keyword">await</span> db.<span class="hljs-title function_">collection</span>(collectionName).<span class="hljs-title function_">countDocuments</span>();
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">`Number of documents in collection: <span class="hljs-subst">${count}</span>`</span>);

<span class="hljs-comment">// Run a MongoDB command</span>
<span class="hljs-keyword">const</span> command = { <span class="hljs-attr">ping</span>: <span class="hljs-number">1</span> };
<span class="hljs-keyword">const</span> result = <span class="hljs-keyword">await</span> db.<span class="hljs-title function_">command</span>(command);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">'Command result:'</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(result);

} <span class="hljs-keyword">finally</span> { <span class="hljs-comment">// Close the connection</span> <span class="hljs-keyword">await</span> client.<span class="hljs-title function_">close</span>(); } }

<span class="hljs-comment">// Execute the main function</span> <span class="hljs-title function_">main</span>().<span class="hljs-title function_">catch</span>(<span class="hljs-variable language_">console</span>.<span class="hljs-property">error</span>);</pre></div><p id="0968">There are several ways to use MongoDB:</p><ol><li><i>Using the MongoDB shell: MongoDB comes with a command-line interface called the Mongo shell, which can be used to interact with the MongoDB server. This is the most direct way to interact with MongoDB and is useful for performing administrative tasks or running quick queries. To start the Mongo shell, open a terminal and type “mongo”.</i></li><li><i>Using a MongoDB driver: MongoDB drivers are available for most popular programming languages such as Python, Java, C#, and JavaScript. These drivers allow you to interact with MongoDB from your application code.</i></li><li><i>Using MongoDB Compass: MongoDB Compass is a graphical user interface (GUI) for MongoDB that allows you to interact with MongoDB in a more user-friendly way. It provides a visual representation of your data, allows you to run queries and perform administrative tasks, and even provides a built-in tool for monitoring and troubleshooting.</i></li><li><i>Using MongoDB Atlas: MongoDB Atlas is a fully managed MongoDB service provided by MongoDB Inc. It runs on the cloud and provides an easy way to set up, operate, and scale MongoDB clusters.</i></li></ol><p id="5a94">Snippet —</p><figure id="1764"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*5kNyxabokb3sJhRMj9WRtg.png"><figcaption></figcaption></figure><h1 id="8cec">That’s it for now. Start with Day 1 of 15 days of Advanced SQL series</h1><div id="3cac" class="link-block"> <a href="https://readmedium.com/day-1-of-15-days-of-advanced-sql-series-a3676272dd5f"> <div> <div> <h2>Day 1 of 15 Days of Advanced SQL Series</h2> <div><h3>Both Basics and Advanced SQL covered…</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*QCqJqD4IIC8bUQGd)"></div> </div> </div> </a> </div><p id="00f9"><b><i>Let me know if you have questions in the comment section below. Subscribe/ Follow, Like/Clap as it would encourage me to write more in my free time</i></b></p><p id="6bdd"><b><i>Stay Tuned!!</i></b></p><h2 id="1275">Read More —</h2><h1 id="e6db">11 most important System Design Base Concepts</h1><blockquote id="07c4"><p><a href="https://readmedium.com/complete-system-design-series-part-1-45bf9c8654bc"><b>1. System design basics</b></a></p></blockquote><blockquote id="5e90"><p><a href="https://readmedium.com/complete-system-design-series-part-2-922f45f2faaf"><b>2. Horizontal and vertical scaling</b></a></p></blockquote><blockquote id="e615"><p><a href="https://readmedium.com/part-3-complete-system-design-series-e1362baa8a4c"><b>3. Load balancing and Message queues</b></a></p></blockquote><blockquote id="ba0d"><p><a href="https://readmedium.com/part-4-complete-system-design-series-138bc9fbcfc0"><b>4. High level design and low level design, Consistent Hashing, Monolithic and Microservices architecture</b></a></p></blockquote><blockquote id="9480"><p><a href="https://readmedium.com/part-5-complete-system-design-series-4b9b04f23608"><b>5. Caching, Indexing, Proxies</b></a></p></blockquote><blockquote id="786d"><p><a href="https://readmedium.com/part-6-complete-system-design-series-59a2d8bbf1ed"><b>6. Networking, How Browsers work, Content Network Delivery ( CDN)</b></a></p></blockquote><blockquote id="1e02"><p><a href="https://readmedium.com/part-7-complete-system-design-series-1bef528923d6"><b>7. Database Sharding, CAP Theorem, Database schema Design</b></a></p></blockquote><blockquote id="ed73"><p><a href="https://readmedium.com/part-8-complete-system-design-series-57bc88433c8e"><b>8. Concurrency, API, Components + OOP + Abstraction</b></a></p></blockquote><blockquote id="6213"><p><a href="https://readmedium.com/part-9-complete-system-design-series-df975c85ec51"><b>9. Estimation and Planning, Performance</b></a></p></blockquote><blockquote id="c502"><p><b>10. <a href="https://readmedium.com/part-10-complete-system-design-series-523b4dd978bf?sk=741f92929c8639a2e4cf218521e8cc4a">Map Reduce, Patterns and Microservices</a></b></p></blockquote><blockquote id="967c"><p><b>11. <a href="https://naina0412.medium.com/part-11-complete-system-design-series-9c8efbc0237a?sk=5bddf2adc78ea4947ae88ab21c94af1c">SQL vs NoSQL and Cloud</a></b></p></blockquote><blockquote id="767e"><p><a href="https://readmedium.com/most-popular-system-design-questions-mega-compilation-45218129fe26"><b>12. Most Popular System Design Questions</b></a></p></blockquote><blockquote id="33a4"><p><b>13. <a href="https://readmedium.com/day-3-of-system-design-case-studies-series-875df4b766b9?sk=1133c9135f849f4497400a6b9caf5c2e">System Design Template — How to solve any System Design Question</a></b></p></blockquote><blockquote id="7526"><p><a href="https://readmedium.com/quick-roundup-solved-system-design-case-studies-6ad776d437cf?sk=e42f56968e1b592382f484c222e7c111"><b>14. Quick RoundUp : Solved System Design Case Studies</b></a></p></blockquote><h1 id="c583">Some of the other best Series —</h1><blockquote id="ca4e"><p><a href="https://readmedium.com/day-1-day-60-quick-recap-of-60-days-of-data-science-and-ml-6fc021643d1?sk=4e75e043b7630a9f963562ebac94e129"><b>60 days of Data Science and ML Series with projects</b></a></p></blockquote><blockquote id="1ff6"><p><a href="https://readmedium.com/quick-recap-30-days-of-natural-language-processing-nlp-with-projects-series-ceb674e3c09b?sk=ca09b27b3d5867f23ab4dc367b6c0c32"><b>30 Days of Natural Language Processing ( NLP) Series</b></a></p></blockquote><blockquote id="c2cf"><p><a href="https://readmedium.com/day-1-of-30-days-of-machine-learning-ops-7c299e4b09be?sk=4ab48350a5c359fc157109e48b1d738f"><b>30 days of Machine Learning Ops</b></a></p></blockquote><blockquote id="5c01"><p><a href="https://readmedium.com/day-1-of-30-days-of-data-structures-and-algorithms-and-system-design-simplified-dsa-and-system-965e860ec677?sk=aa49bdbc46a72f600cb51774f0aea6b6"><b>30 days of Data Structures and Algorithms and System Design Simplified</b></a></p></blockquote><blockquote id="f2fd"><p><a href="https://readmedium.com/day-1-of-60-days-of-deep-learning-with-projects-series-4a5caa305cf6?sk=89f3d43dd450035546bf3a8cf85bb125"><b>60 Days of Deep Learning with Projects Series</b></a></p></blockquote><blockquote id="b8a0"><p><a href="https://readmedium.com/day-1-of-30-days-of-data-engineering-894822fcb128?sk=76ba558bfe2d9f85cbe741e505295531"><b>30 days of Data Engineering with projects Series</b></a></p></blockquote><blockquote id="9d85"><p><a href="https://readmedium.com/day-1-data-science-and-ml-research-papers-simplified-a68b00a3b1c4?sk=56136229ff738bd734f19d2b6953f78c"><b>Data Science and Machine Learning Research ( papers) Simplified</b></a><b> **</b></p></blockquote><blockquote id="fb06"><p><a href="https://readmedium.com/100-days-your-data-science-and-ml-degree-part-3-c621ecfdf711?sk=1a8c7b0c204d73432d56b7d1a3a26474"><b>100 days : Your Data Science and Machine Learning Degree Series with projects</b></a></p></blockquote><blockquote id="5203"><p><a href="https://ai.plainenglish.io/23-data-science-techniques-you-should-know-61bc2c9d1b3a?sk=1680c36193eb22198974c9008d62a33c"><b>23 Data Science Techniques You Should Know</b></a></p></blockquote><blockquote id="ac12"><p><a href="https://readmedium.com/mega-post-tech-interview-the-only-list-of-questions-you-need-to-practice-ee349ea197bb?sk=fac3614684daff4b50a70c0a71e4d528"><b>Tech Interview Series — Curated List of coding questions</b></a></p></blockquote><blockquote id="dede"><p><a href="https://readmedium.com/system-design-made-easy-quick-recap-of-complete-system-design-34af7e3aedfb?sk=bdd6a19edc1f3ce4a5064923f5b68721"><b>Complete System Design with most popular Questions Series</b></a></p></blockquote><blockquote id="6508"><p><a href="https://readmedium.com/complete-data-preprocessing-and-data-visualization-with-projects-mega-compilation-part-2-41584ef0920e?sk=842390da51689b8d43148c3980570db0"><b>Complete Data Visualization and Pre-processing Series with projects</b></a></p></blockquote><blockquote id="409a"><p><a href="https://readmedium.com/complete-python-and-projects-mega-compilation-7ec8f7adfe71?sk=ee0ecf43f23c6dd44dd35d984b3e5df4"><b>Complete Python Series with Projects</b></a></p></blockquote><blockquote id="67e0"><p><a href="https://readmedium.com/complete-advanced-python-with-projects-mega-compilation-part-6-729c1826032b?sk=7faffe20f8039fa57099f7a372b6d665"><b>Complete Advanced Python Series with Projects</b></a></p></blockquote><blockquote id="4ded"><p><a href="https://readmedium.com/my-list-of-kaggle-best-notebooks-topic-wise-data-science-and-machine-learning-part-2-84772863e9ae?sk=5ed02e419854a6c11add3ddc1e52947f"><b>Kaggle Best Notebooks that will teach you the most</b></a></p></blockquote><blockquote id="4b2e"><p><a href="https://medium.datadriveninvestor.com/the-complete-developers-guide-to-git-6a23125996e1?sk=e30479bbe713930ea93018e1a46d9185"><b>Complete Developers Guide to Git</b></a></p></blockquote><blockquote id="732e"><p><a href="https://readmedium.com/6-exceptional-github-repos-for-all-developers-part-1-21e8fa04e150?sk=9140b249af6fe73d45717185fad48962"><b>Exceptional Github Repos</b></a><b> — Part 1</b></p></blockquote><blockquote id="7079"><p><a href="https://readmedium.com/6-exceptional-github-repos-for-all-developers-part-2-3eec9a68c31c?sk=8e31d0eb7eb1d2d0bbbcecaa66bd4e7e"><b>Exceptional Github Repos</b></a><b> — Part 2</b></p></blockquote><blockquote id="d9c6"><p><a href="https://medium.datadriveninvestor.com/best-resources-for-data-science-and-machine-learning-full-list-5ceb9a2791bf?sk=cf85b2cef95560c58509877a794577ff"><b>All the Data Science and Machine Learning Resources</b></a></p></blockquote><blockquote id="b2cb"><p><a href="https://medium.datadriveninvestor.com/210-machine-learning-projects-with-source-code-that-you-can-build-today-721b035649e0?sk=da5f593572a0261a6314afad99a0356c"><b>210 Machine Learning Projects</b></a></p></blockquote><h2 id="9083">Tech Newsletter —</h2><blockquote id="f86c"><p>If you are interested, you can join my newsletter through which I send tech interview tips, techniques, patterns, hacks — Software Development, ML, Data Science, Startups and Technology projects to more than 30K readers. You can subscribe to <b>Tech Brew :</b></p></blockquote><div id="8d5c" class="link-block"> <a href="https://naina0405.substack.com/"> <div> <div> <h2>Ignito</h2> <div><h3>Data Science, ML, AI and more… Click to read Ignito, by Naina Chaturvedi, a Substack publication. Launched 7 months…</h3></div> <div><p>naina0405.substack.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*_ER1J-h50iqAjH70)"></div> </div> </div> </a> </div><p id="eb48"><b><i>For Python Projects —</i></b></p><div id="22a4" class="link-block"> <a href="https://readmedium.com/complete-python-and-projects-mega-compilation-7ec8f7adfe71"> <div> <div> <h2>Complete Python And Projects — Mega Compilation</h2> <div><h3>Everything that you need to know in Python with Projects…</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*NnCSMN6etFjjw4Jn.jpg)"></div> </div> </div> </a> </div><div id="471c" class="link-block"> <a href="https://medium.datadriveninvestor.com/analyzing-video-using-python-opencv-and-numpy-5471cab200c4"> <div> <div> <h2>Analyzing Video using Python, OpenCV and NumPy</h2> <div><h3>With Code Implementation…</h3></div> <div><p>medium.datadriveninvestor.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*PYNCDW3IXI2BcT5f.jpg)"></div> </div> </div> </a> </div><p id="f199"><b><i>For complete 60 days of Data Science and ML : Day 1 — Day 60 : Quick Recap of 60 days of Data Science and ML</i></b></p><div id="9d77" class="link-block"> <a href="https://readmedium.com/day-1-day-60-quick-recap-of-60-days-of-data-science-and-ml-6fc021643d1"> <div> <div> <h2>Day 1 — Day 60 : Quick Recap of 60 days of Data Science and ML</h2> <div><h3>Connect the ML dots…</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*ZfJ1yKIzPLGABAI_.png)"></div> </div> </div> </a> </div><p id="1253"><b><i>Follow for more updates. Stay tuned and keep coding!</i></b></p><h1 id="21c3">For other projects, tune to —</h1><p id="b31f"><b>Build Machine Learning Pipelines( With Code)</b></p><div id="5b37" class="link-block"> <a href="https://medium.datadriveninvestor.com/build-machine-learning-pipelines-with-code-part-1-bd3ed7152124"> <div> <div> <h2>Build Machine Learning Pipelines( With Code) — Part 1</h2> <div><h3>Complete implementation…</h3></div> <div><p>medium.datadriveninvestor.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*KdToBD8RDMBH4jXM.png)"></div> </div> </div> </a> </div><p id="946c"><b>Recurrent Neural Network with Keras</b></p><div id="f317" class="link-block"> <a href="https://medium.datadriveninvestor.com/recurrent-neural-network-with-keras-b5b5f6fe5187"> <div> <div> <h2>Recurrent Neural Network with Keras</h2> <div><h3>Project Implementation and cheatsheet…</h3></div> <div><p>medium.datadriveninvestor.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*xs3Dya3qQBx6IU7C.png)"></div> </div> </div> </a> </div><p id="ec53"><b>Clustering Geolocation Data in Python using DBSCAN and K-Means</b></p><div id="2b3e" class="link-block"> <a href="https://medium.datadriveninvestor.com/clustering-geolocation-data-in-python-using-dbscan-and-k-means-3705d9f44522"> <div> <div> <h2>Clustering Geolocation Data in Python using DBSCAN and K-Means</h2> <div><h3>Project Implementation…</h3></div> <div><p>medium.datadriveninvestor.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*0uPCZnohdaPCO4NN.png)"></div> </div> </div> </a> </div><p id="a29c"><b>Facial Expression Recognition using Keras</b></p><div id="ccaa" class="link-block"> <a href="https://medium.datadriveninvestor.com/facial-expression-recognition-using-keras-cbdd661a0a54"> <div> <div> <h2>Facial Expression Recognition using Keras</h2> <div><h3>Project Implementation…</h3></div> <div><p>medium.datadriveninvestor.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*CGch7hzdjg1fpgKy.jpg)"></div> </div> </div> </a> </div><p id="0db7"><b>Hyperparameter Tuning with Keras Tuner</b></p><div id="6dff" class="link-block"> <a href="https://medium.datadriveninvestor.com/hyperparameter-tuning-with-keras-tuner-3a609d3fd85b"> <div> <div> <h2>Hyperparameter Tuning with Keras Tuner</h2> <div><h3>Project Implementation….</h3></div> <div><p>medium.datadriveninvestor.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*jlaEz8AZaptNWHEr.png)"></div> </div> </div> </a> </div><p id="fed8"><b>Custom Layers in Keras</b></p><div id="e4fd" class="link-block"> <a href="https://medium.datadriveninvestor.com/custom-layers-in-keras-de5f793217aa"> <div> <div> <h2>Custom Layers in Keras</h2> <div><h3>Code implementation …</h3></div> <div><p>medium.datadriveninvestor.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*1IH67KJadqeqeO01.png)"></div> </div> </div> </a> </div></article></body>

Day 15 of 15 Days of Advanced SQL Series

Pic credits : FOSS Linux

Welcome back peeps. Hope all’s well.

Happy to share that this is the last post of 15 days of Advanced SQL and what we have covered so far is listed below —

Day 1 : SQL Basics and Kick start of Advanced SQL Series

Day 2 : SQL Basics, Query Structure, Built In functions Conditions

Day 3 : Most Important Commands, Joins and Filters

Day 4 : Set Theory Operations, Stored Procedures and CASE statements in SQL

Day 5 : Wildcards, Aggregation and Sequences in SQL

Day 6 : Subqueries, Group by, order by and Having clauses in SQL and Analytical Functions

Day 7 : Window Functions, Grouping Sets and Constraints in SQL

Day 8 : BigQuery Basics, SELECT, FROM, WHERE and Date and Extract in BigQuery

Day 9 : Common Expression Table, UNNEST Clause, SQL vs NoSQL Databases

Day 10 : Triggers, Pivot and Cursors in SQL

Day 11 : Views, Indexes and Auto Increment in SQL

Day 12 : Query optimizations, Performance tuning in SQL

Day 13 : Introduction to MySQL, PostgreSQL and Mongo DB, Comparison between MySQL and PostgreSQL and Mongo DB, Introduction to SQL and NoSQL Databases

Day 14 : MySQL in Depth

Day 15 : PostgreSQL and MongoDB inDepth

Github for Advanced SQL that you can follow —

Projects Videos —

All the projects, data structures, SQL, algorithms, system design, Data Science and ML , Data Analytics, Data Engineering, , Implemented Data Science and ML projects, Implemented Data Engineering Projects, Implemented Deep Learning Projects, Implemented Machine Learning Ops Projects, Implemented Time Series Analysis and Forecasting Projects, Implemented Applied Machine Learning Projects, Implemented Tensorflow and Keras Projects, Implemented PyTorch Projects, Implemented Scikit Learn Projects, Implemented Big Data Projects, Implemented Cloud Machine Learning Projects, Implemented Neural Networks Projects, Implemented OpenCV Projects,Complete ML Research Papers Summarized, Implemented Data Analytics projects, Implemented Data Visualization Projects, Implemented Data Mining Projects, Implemented Natural Leaning Processing Projects, MLOps and Deep Learning, Applied Machine Learning with Projects Series, PyTorch with Projects Series, Tensorflow and Keras with Projects Series, Scikit Learn Series with Projects, Time Series Analysis and Forecasting with Projects Series, ML System Design Case Studies Series videos will be published on our youtube channel ( just launched).

Subscribe today!

System Design Case Studies — In Depth

Design Instagram

Design Messenger App

Design Twitter

Design URL Shortener

Design Dropbox

Design Youtube

Design API Rate Limiter

Design Web Crawler

Design Facebook’s Newsfeed

Design Yelp

Design Uber

Design Tinder

Design Tiktok

Design Whatsapp

Most Popular System Design Questions

Mega Compilation : Solved System Design Case studies

Complete Data Structures and Algorithm Series

Complexity Analysis

Backtracking

Sliding Window

Greedy Technique

Two pointer Technique

Arrays

Linked List

Strings

Stack

Queues

Hash Table/Hashing

Binary Search

1- D Dynamic Programming

Divide and Conquer Technique

Recursion

Github —

Let’s get started with Day 15.

PostgreSQL is a powerful, open-source, object-relational database management system (ORDBMS). It is known for its reliability, stability, and robustness.

  • PostgreSQL stores data in tables, which are organized into a schema. Each table has a set of columns and rows, similar to a spreadsheet. The data in each column must be of a specific data type, such as integer, text, or date.
  • When a query is executed in PostgreSQL, the query optimizer analyses the query and generates an execution plan. The execution plan is a set of instructions that the database uses to retrieve the requested data. The optimizer uses statistics about the table and indexes to determine the most efficient way to execute the query.
  • PostgreSQL uses a multi-version concurrency control (MVCC) system to handle concurrent access to the same data. This allows multiple users to read and write to the same table at the same time without interfering with each other.
  • In addition to its powerful query engine, PostgreSQL also includes a variety of features such as support for full-text search, spatial data, and user-defined functions written in a variety of programming languages.
  • It also supports data replication and high availability, which allows to have multiple copies of the data and failover mechanisms to ensure that the service is always available in case of any failure.

Overall, PostgreSQL is a highly customizable and extensible database management system that is well-suited for a wide range of use cases, from small applications to large-scale, high-traffic systems.

MongoDB is a NoSQL, cross-platform, document-oriented database management system. It uses a document data model, where data is represented in BSON (binary JSON) format, which is similar to JSON format.

This data model allows MongoDB to handle unstructured data, such as images, videos, and audio files, in addition to traditional structured data such as numbers, strings, and dates. MongoDB allows for easy scalability, high performance and high availability, due to its built-in sharding and automatic failover capabilities.

Note : A full course on practical PostgreSQL and MongoDB is under progress and would be published here (subscribe today) —

We have already covered an introduction to PostgreSQL database in our previous post (Day 13).

PostgreSQL is a very powerful open source relational database system which is widely used by the developers to build robust applications and let administrators protect data securely and provide data integrity. It has many query optimizations features, indexing techniques and supports ACID properties.

Some important functions —

CONCAT(): The CONCAT() function is used to concatenate two or more strings together.

-- Concatenate two strings
SELECT CONCAT('Hello', 'World') AS result;

EXTRACT(): The EXTRACT() function is used to extract a specific part of a date or timestamp, such as year, month, day, hour, etc.

-- Extract the year from a date column
SELECT EXTRACT(YEAR FROM date_column) AS year FROM your_table;

COALESCE(): The COALESCE() function is used to return the first non-null value from a set of values.

-- Return the first non-null value from multiple columns
SELECT COALESCE(column1, column2, column3) AS result FROM your_table;

DATE_TRUNC(): The DATE_TRUNC() function is used to truncate a date or timestamp to a specified precision, such as year, month, day, etc.

-- Truncate a date column to the month precision
SELECT DATE_TRUNC('month', date_column) AS truncated_date FROM your_table;

STRING_AGG(): The STRING_AGG() function is used to concatenate values from multiple rows into a single string, with a specified delimiter.

-- Concatenate values from multiple rows into a single string with a comma delimiter
SELECT STRING_AGG(column_name, ', ') AS concatenated_values FROM your_table;

JSONB Functions: PostgreSQL provides a rich set of functions for working with JSONB data type, which allows storing and querying JSON documents.

-- Extract value from JSON document
SELECT jsonb_extract_path('{"name": "John", "age": 30}', 'name');
-- Check if JSON document contains a specific key
SELECT '{"name": "John", "age": 30}'::jsonb ? 'age';
-- Modify JSON document by adding or updating a key-value pair
SELECT jsonb_set('{"name": "John"}', '{age}', '30'::jsonb, true);

Window Functions: Window functions perform calculations across a set of rows that are related to the current row. They allow you to perform complex aggregations and calculations without the need for subqueries or joins.

-- Calculate the average salary for each department, along with the total and rank
SELECT department, AVG(salary) OVER (PARTITION BY department) AS avg_salary,
       SUM(salary) OVER (PARTITION BY department) AS total_salary,
       RANK() OVER (PARTITION BY department ORDER BY salary DESC) AS rank
FROM employees;

Common Table Expressions (CTEs): CTEs are temporary result sets that can be used within a query. They allow you to break down complex queries into more manageable and readable parts.

-- Use CTE to calculate the total sales for each product category
WITH category_sales AS (
    SELECT category, SUM(sales) AS total_sales
    FROM sales
    GROUP BY category
)
SELECT category, total_sales
FROM category_sales
ORDER BY total_sales DESC;

Full-Text Search Functions: PostgreSQL provides full-text search capabilities, allowing you to perform advanced text search operations.

-- Search for documents containing specific keywords
SELECT *
FROM documents
WHERE to_tsvector('english', content) @@ to_tsquery('english', 'search keywords');

In this post we will go in depth and cover the most important constructs of PostgreSQL.

  • Access the PostgreSQL server
  • Connect to a database
  • List database, views and tables
  • Create, Delete and Alter databases
  • Views and Indexes
  • Query data from tables
  • SET operations
  • Insert, Delete and Update
  • Performance and Statistics

Implementation —

import psycopg2

# Access the PostgreSQL server
conn = psycopg2.connect(
    host="your_host",
    database="your_database",
    user="your_username",
    password="your_password"
)

# Connect to a database
cur = conn.cursor()
cur.execute("SELECT version();")
print(cur.fetchone()[0])

# List databases
cur.execute("SELECT datname FROM pg_database;")
databases = cur.fetchall()
print("Databases:")
for db in databases:
    print(db[0])

# List views
cur.execute("SELECT table_name FROM information_schema.views WHERE table_schema = 'public';")
views = cur.fetchall()
print("Views:")
for view in views:
    print(view[0])

# List tables
cur.execute("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_type = 'BASE TABLE';")
tables = cur.fetchall()
print("Tables:")
for table in tables:
    print(table[0])

# Create a database
cur.execute("CREATE DATABASE new_database;")
conn.commit()
print("New database created.")

# Delete a database
cur.execute("DROP DATABASE existing_database;")
conn.commit()
print("Existing database deleted.")

# Alter a database
cur.execute("ALTER DATABASE existing_database RENAME TO new_name;")
conn.commit()
print("Database name altered.")

# Create a view
cur.execute("CREATE VIEW new_view AS SELECT * FROM table_name;")
conn.commit()
print("New view created.")

# Create an index
cur.execute("CREATE INDEX idx_column ON table_name (column_name);")
conn.commit()
print("Index created.")

# Query data from a table
cur.execute("SELECT * FROM table_name WHERE condition;")
data = cur.fetchall()
for row in data:
    print(row)

# Perform SET operations
cur.execute("SELECT * FROM table1 UNION SELECT * FROM table2;")
union_result = cur.fetchall()
print("Union result:")
for row in union_result:
    print(row)

# Insert data into a table
cur.execute("INSERT INTO table_name (column1, column2) VALUES (%s, %s);", (value1, value2))
conn.commit()
print("Data inserted.")

# Delete data from a table
cur.execute("DELETE FROM table_name WHERE condition;")
conn.commit()
print("Data deleted.")

# Update data in a table
cur.execute("UPDATE table_name SET column1 = %s WHERE condition;", (new_value,))
conn.commit()
print("Data updated.")

# Get performance statistics
cur.execute("EXPLAIN ANALYZE SELECT * FROM table_name;")
performance_stats = cur.fetchall()
for stat in performance_stats:
    print(stat[0])

# Close the cursor and connection
cur.close()
conn.close()

Let’s get started with important constructs.

Access the PostgreSQL server

To access the server from psql

Syntax —

psql -U [user_name];

Connect to a database and check version

  1. To connect to a database —

Syntax —

\c database_name

2. Check version

Syntax —

psql -V

List database, views and tables

  1. List database

Syntax —

psql -l

2. List views

Syntax —

\dv

3. List tables

Syntax —

\dt

Create, Delete and Alter table in the database

  1. Create new table Database

Syntax —

CREATE TABLE table_name

( primarykey SERIAL PRIMARY KEY, c1 type(size) NOT NULL, … );

2. Delete Table

Syntax —

DROP TABLE table_name CASCADE;

3. Alter Table

Syntax —

ALTER TABLE table_name DROP COLUMN column_name;

Views , triggers and Indexes

1.Create a new view

Syntax —

CREATE VIEW view_name

As SELECT_STATEMENT;

2. Create or replace a view

Syntax —

CREATE OR REPLACE VIEW view_name

As SELECT_STATEMENT;

3.Drop a view

Syntax —

DROP VIEW view_name;

4. Rename a view

Syntax —

RENAME TABLE view_name

TO new_name;

5. Show views

Syntax —

SHOW FULL TABLES

FROM database_name

WHERE tabletype = ‘VIEW’;

Triggers

  1. Create a new trigger

Syntax —

CREATE TRIGGER trigger_name

BEFORE/AFTER

SQL Statement (INSERT/UPDATE/DELETE/ALTER)

ON table_name

FOR EACH ROW SET operation;

2. Drop a trigger

Syntax —

DROP Trigger trigger_name;

3. Show triggers

Syntax —

SHOW Triggers FROM database_name

WHERE condition

Indexes

To create Indexes —

CREATE INDEX index_name

ON table (column_1, column_2, …column_n)

Query data from tables

  1. Select

Syntax —

SELECT t1, t2, … FROM table_name;

2. Search using like

Syntax —

SELECT * FROM table_name WHERE column_name LIKE ‘%ny%’

SELECT * FROM table_name WHERE column_name LIKE ‘_ewyork’

SELECT * FROM table_name WHERE column_name LIKE ‘_e_yo_k’

SELECT * FROM table_name WHERE column_name LIKE ‘[n-y]%’

SELECT * FROM table_name WHERE column_name LIKE ‘[adf]%’

3. Distinct

Syntax —

SELECT DISTINCT (column_name) FROM table_name;

4. Joins

Syntax —

SELECT column_names

FROM table1 JOIN table2

ON column_name1 = column_name2

WHERE condition

5. Group by

Syntax —

SELECT column_names

FROM table

WHERE condition

GROUP BY column_names

6. Order by

Syntax —

SELECT column_names

FROM table

WHERE condition

ORDER BY column_names

7. Filter Data

Syntax —

Select t1

from table_name

Where t1 > 4

Using other comparison Operator —

Select t1

from table_name

Where t1 != ‘string’

Select t1,t2

from table_name

Where t1 == 17 AND t2 == ‘string’

SET operations

For UNION

Syntax —

Select t1, t2 FROM table1 UNION Select r1, r2 FROM table2

INTERSECT

Syntax —

Select t1, t2

FROM table_name

WHERE Condition

INTERSECT

Select r1, r2

FROM table_name

WHERE Condition

EXCEPT

Syntax —

Select t1, t2

FROM table_name

WHERE Condition

EXCEPT

Select r1, r2

FROM table_name

WHERE Condition

Insert, Delete and Update

  1. Insert

Syntax —

Insert into table_name ( column_1, column_2) values (values_1,values_2,…values_n);

2. Update

Syntax —

Update table_name SET Column_name = value where Condition;

3. Delete

Syntax —

Delete FROM table_name;

Create Roles and Change the Roles

Create Role

Syntax —

CREATE ROLE role_name;

Change the Role

Syntax —

SET Role newrole_name;

Performance and Statistics

For statistics collection

Syntax —

ANALYZE table_name;

To show and execute query plan

Syntax —

EXPLAIN ANALYZE sql_query;

Snippet —

MongoDB

Pic credits : Quora

MongoDB works by storing data in a document format, where each document is a collection of key-value pairs. These documents are stored in collections, which are similar to tables in a relational database.

Each document in a collection can have a unique structure, meaning that the fields in one document do not have to match the fields in another document within the same collection.

  • When a client sends a request to MongoDB, the request is passed to the MongoDB server, which then performs the requested operation on the appropriate collection or document. The MongoDB server uses a storage engine to handle the underlying storage and retrieval of data. The default storage engine is called WiredTiger, but MongoDB also supports other storage engines such as MMAPv1 and RocksDB.
  • One of the key features of MongoDB is its ability to scale horizontally. This is achieved through a process called sharding, where data is split across multiple servers, called shards. Each shard is responsible for storing a portion of the data, and the MongoDB server uses a routing process to determine which shard a particular request should be sent to.
  • MongoDB also provides automatic failover capabilities, where if a primary server goes down, a secondary server is automatically promoted to primary to ensure high availability. Additionally, MongoDB has built-in support for replica sets, which are groups of servers that maintain a copy of the same data, providing additional redundancy and failover protection.

Overall, MongoDB is designed to provide a flexible, high-performance, and highly available system for storing and querying large amounts of unstructured data.

Some important functions —

Find: The find function is used to query documents in a collection based on specified criteria.
// Find documents in the "users" collection where the age is greater than 25
db.users.find({ age: { $gt: 25 } });
InsertOne: The insertOne function is used to insert a single document into a collection.
// Insert a new document into the "users" collection
db.users.insertOne({ name: "John", age: 30 });
UpdateOne: The updateOne function is used to update a single document in a collection.
// Update the document with name "John" in the "users" collection, set age to 35
db.users.updateOne({ name: "John" }, { $set: { age: 35 } });
DeleteOne: The deleteOne function is used to delete a single document from a collection.
// Delete the document with name "John" from the "users" collection
db.users.deleteOne({ name: "John" });
Aggregate: The aggregate function is used to perform advanced aggregation operations on a collection, such as grouping, sorting, and calculating aggregate values.
// Calculate the average age of users in the "users" collection
db.users.aggregate([
  { $group: { _id: null, avgAge: { $avg: "$age" } } }
]);
$lookup: The $lookup function is used for performing a left outer join between two collections and retrieving matched documents from the joined collection.
// Perform a left outer join between "orders" and "customers" collections
db.orders.aggregate([
  {
    $lookup: {
      from: "customers",
      localField: "customerId",
      foreignField: "_id",
      as: "customer"
    }
  }
]);
$group: The $group function is used for grouping documents based on specified criteria and performing aggregate operations on grouped data.
// Group documents in the "orders" collection by customerId and calculate the total amount for each customer
db.orders.aggregate([
  {
    $group: {
      _id: "$customerId",
      totalAmount: { $sum: "$amount" }
    }
  }
]);
$unwind: The $unwind function is used to deconstruct an array field and generate a new document for each element of the array.
// Unwind the "tags" array field in the "articles" collection
db.articles.aggregate([
  { $unwind: "$tags" }
]);
$push: The $push function is used to add a value to an array field in a document.
// Add a new tag to the "tags" array field in the document with _id "12345" in the "articles" collection
db.articles.updateOne(
  { _id: "12345" },
  { $push: { tags: "newtag" } }
);
$regex: The $regex function is used for performing regular expression-based pattern matching in queries.
// Find documents in the "users" collection where the name starts with "J"
db.users.find({ name: { $regex: "^J" } });

Here are some important MongoDB commands and examples:

  1. show dbs - This command is used to display all the databases in the MongoDB server.
  2. use <dbname> - This command is used to switch to a specific database. For example, use testdb will switch to the "testdb" database.
  3. db.createCollection(name, options) - This command is used to create a new collection in the current database. For example, db.createCollection("employees") will create a new collection named "employees" in the current database.
  4. db.collection.insert(document) - This command is used to insert a new document into a collection. For example, db.employees.insert({name: "John Doe", age: 30, job: "Developer"}) will insert a new document into the "employees" collection.
  5. db.collection.find() - This command is used to find all documents in a collection. For example, db.employees.find() will return all documents in the "employees" collection.
  6. db.collection.update(query, update, options) - This command is used to update documents in a collection. For example, db.employees.update({name: "John Doe"}, {$set: {age: 35}}) will update the document where the name is "John Doe" and set the age to 35.
  7. db.collection.remove(query, justOne) - This command is used to remove documents from a collection. For example, db.employees.remove({name: "John Doe"}) will remove the document where the name is "John Doe" from the "employees" collection.
  8. db.collection.drop() - This command is used to delete a collection. For example, db.employees.drop() will delete the "employees" collection.
  9. db.collection.count() - This command is used to count the number of documents in a collection. For example, db.employees.count() will return the number of documents in the "employees" collection.
  10. db.runCommand({command: value}) - This command is used to run any MongoDB command. For example, db.runCommand({ping:1}) will return the status of the MongoDB server.

Implementation —

// Connect to the MongoDB server
const MongoClient = require('mongodb').MongoClient;
const url = 'mongodb://localhost:27017';
const client = new MongoClient(url, { useUnifiedTopology: true });

async function main() {
  try {
    // Connect to the server
    await client.connect();

    // Show all databases
    const databases = await client.db().admin().listDatabases();
    console.log('Databases:');
    databases.databases.forEach((db) => {
      console.log(db.name);
    });

    // Switch to a specific database
    const dbName = 'testdb';
    const db = client.db(dbName);
    console.log(`Switched to database: ${dbName}`);

    // Create a new collection
    const collectionName = 'employees';
    await db.createCollection(collectionName);
    console.log(`Created collection: ${collectionName}`);

    // Insert a new document
    const document = { name: 'John Doe', age: 30, job: 'Developer' };
    await db.collection(collectionName).insertOne(document);
    console.log('Inserted a new document into the collection');

    // Find all documents in the collection
    const documents = await db.collection(collectionName).find().toArray();
    console.log('Documents:');
    console.log(documents);

    // Update a document
    const query = { name: 'John Doe' };
    const update = { $set: { age: 35 } };
    await db.collection(collectionName).updateOne(query, update);
    console.log('Updated document');

    // Remove a document
    await db.collection(collectionName).deleteOne(query);
    console.log('Removed document');

    // Delete the collection
    await db.collection(collectionName).drop();
    console.log(`Deleted collection: ${collectionName}`);

    // Count the number of documents in the collection
    const count = await db.collection(collectionName).countDocuments();
    console.log(`Number of documents in collection: ${count}`);

    // Run a MongoDB command
    const command = { ping: 1 };
    const result = await db.command(command);
    console.log('Command result:');
    console.log(result);
  } finally {
    // Close the connection
    await client.close();
  }
}

// Execute the main function
main().catch(console.error);

There are several ways to use MongoDB:

  1. Using the MongoDB shell: MongoDB comes with a command-line interface called the Mongo shell, which can be used to interact with the MongoDB server. This is the most direct way to interact with MongoDB and is useful for performing administrative tasks or running quick queries. To start the Mongo shell, open a terminal and type “mongo”.
  2. Using a MongoDB driver: MongoDB drivers are available for most popular programming languages such as Python, Java, C#, and JavaScript. These drivers allow you to interact with MongoDB from your application code.
  3. Using MongoDB Compass: MongoDB Compass is a graphical user interface (GUI) for MongoDB that allows you to interact with MongoDB in a more user-friendly way. It provides a visual representation of your data, allows you to run queries and perform administrative tasks, and even provides a built-in tool for monitoring and troubleshooting.
  4. Using MongoDB Atlas: MongoDB Atlas is a fully managed MongoDB service provided by MongoDB Inc. It runs on the cloud and provides an easy way to set up, operate, and scale MongoDB clusters.

Snippet —

That’s it for now. Start with Day 1 of 15 days of Advanced SQL series

Let me know if you have questions in the comment section below. Subscribe/ Follow, Like/Clap as it would encourage me to write more in my free time

Stay Tuned!!

Read More —

11 most important System Design Base Concepts

1. System design basics

2. Horizontal and vertical scaling

3. Load balancing and Message queues

4. High level design and low level design, Consistent Hashing, Monolithic and Microservices architecture

5. Caching, Indexing, Proxies

6. Networking, How Browsers work, Content Network Delivery ( CDN)

7. Database Sharding, CAP Theorem, Database schema Design

8. Concurrency, API, Components + OOP + Abstraction

9. Estimation and Planning, Performance

10. Map Reduce, Patterns and Microservices

11. SQL vs NoSQL and Cloud

12. Most Popular System Design Questions

13. System Design Template — How to solve any System Design Question

14. Quick RoundUp : Solved System Design Case Studies

Some of the other best Series —

60 days of Data Science and ML Series with projects

30 Days of Natural Language Processing ( NLP) Series

30 days of Machine Learning Ops

30 days of Data Structures and Algorithms and System Design Simplified

60 Days of Deep Learning with Projects Series

30 days of Data Engineering with projects Series

Data Science and Machine Learning Research ( papers) Simplified **

100 days : Your Data Science and Machine Learning Degree Series with projects

23 Data Science Techniques You Should Know

Tech Interview Series — Curated List of coding questions

Complete System Design with most popular Questions Series

Complete Data Visualization and Pre-processing Series with projects

Complete Python Series with Projects

Complete Advanced Python Series with Projects

Kaggle Best Notebooks that will teach you the most

Complete Developers Guide to Git

Exceptional Github Repos — Part 1

Exceptional Github Repos — Part 2

All the Data Science and Machine Learning Resources

210 Machine Learning Projects

Tech Newsletter —

If you are interested, you can join my newsletter through which I send tech interview tips, techniques, patterns, hacks — Software Development, ML, Data Science, Startups and Technology projects to more than 30K readers. You can subscribe to Tech Brew :

For Python Projects —

For complete 60 days of Data Science and ML : Day 1 — Day 60 : Quick Recap of 60 days of Data Science and ML

Follow for more updates. Stay tuned and keep coding!

For other projects, tune to —

Build Machine Learning Pipelines( With Code)

Recurrent Neural Network with Keras

Clustering Geolocation Data in Python using DBSCAN and K-Means

Facial Expression Recognition using Keras

Hyperparameter Tuning with Keras Tuner

Custom Layers in Keras

Software Development
Tech
Programming
Data Science
Machine Learning
Recommended from ReadMedium