<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Danish Raza</title>
    <description>The latest articles on DEV Community by Danish Raza (@danishraza).</description>
    <link>https://dev.to/danishraza</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1328023%2F6c18d660-1f9c-4add-a853-0ff35c369f55.png</url>
      <title>DEV Community: Danish Raza</title>
      <link>https://dev.to/danishraza</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/danishraza"/>
    <language>en</language>
    <item>
      <title>call, apply &amp; bind</title>
      <dc:creator>Danish Raza</dc:creator>
      <pubDate>Fri, 15 Mar 2024 21:04:43 +0000</pubDate>
      <link>https://dev.to/danishraza/call-apply-bind-16kj</link>
      <guid>https://dev.to/danishraza/call-apply-bind-16kj</guid>
      <description>&lt;p&gt;call, apply and bind sometimes we called it function borrowing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Call:&lt;/strong&gt; it can map a function with different object like-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let name = {
  firstName: 'Danish',
  lastName: 'Raza',
};

let printFullName = function () {
  console.log(this.firstName + ' ' + this.lastName);
};

let name2 = {
  firstName: 'Lav',
  lastName: 'Singhania',
};

console.log(printFullName.call(name2));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;above code we can just call the function printFullName by passing the object which we want to call.&lt;/p&gt;

&lt;p&gt;call method accept the object as a parameter which you want to call. In above case we are calling name 2 object&lt;/p&gt;

&lt;p&gt;We can also pass the extra parameter to the call function like-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let name = {
  firstName: 'Danish',
  lastName: 'Raza',
};

let printFullName = function (hometown, state) {
  console.log(
    this.firstName + ' ' + this.lastName + ' is from ' + hometown + ', ' + state
  );
};

let name2 = {
  firstName: 'Lav',
  lastName: 'Singhania',
};

console.log(printFullName.call(name2, 'uttam nagar east', 'delhi'));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in the same example we add the two extra parameter named hometown and state. by this way we can pass infinite no of parameters to the function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;apply:&lt;/strong&gt; bind method is same as call method except we pass extra parameters in the array form, like-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let name = {
  firstName: 'Danish',
  lastName: 'Raza',
};

let printFullName = function (hometown, state) {
  console.log(
    this.firstName + ' ' + this.lastName + ' is from ' + hometown + ', ' + state
  );
};

let name2 = {
  firstName: 'Lav',
  lastName: 'Singhania',
};

console.log(printFullName.apply(name2, ['uttam nagar east', 'delhi']));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;bind:&lt;/strong&gt; bind is bit different from these two. In bind method it returns the copy of the existing function that we can invoke later.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let name = {
  firstName: 'Danish',
  lastName: 'Raza',
};

let printFullName = function (hometown, state) {
  console.log(
    this.firstName + ' ' + this.lastName + ' is from ' + hometown + ', ' + state
  );
};

let name2 = {
  firstName: 'Lav',
  lastName: 'Singhania',
};

const printName = printFullName.bind(name2, ['uttam nagar east', 'delhi'])

// printname is the copy of printFullName function which we are invoking below.

printName();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in this code snippet printName is the exact copy of prinFullName functon.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>functionborrowing</category>
      <category>object</category>
    </item>
    <item>
      <title>ACID PROPERTIES</title>
      <dc:creator>Danish Raza</dc:creator>
      <pubDate>Thu, 14 Mar 2024 12:17:09 +0000</pubDate>
      <link>https://dev.to/danishraza/acid-properties-j5i</link>
      <guid>https://dev.to/danishraza/acid-properties-j5i</guid>
      <description>&lt;p&gt;ACID is an acronym that stands for Atomicity, Consistency, Isolation, and Durability, and these are the four key properties of a transaction in SQL. These properties are required for any SQL transaction and guarantee the reliability of database transactions. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feyrwozs01kn5mpw2kar1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feyrwozs01kn5mpw2kar1.png" alt="Image description" width="800" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Atomicity:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;we mean that either the entire transaction takes place at once or doesn’t happen at all. In other words the transaction will happen or not. Not any middle state between these two.&lt;/p&gt;

&lt;p&gt;It involves the following two operations-&lt;br&gt;
&lt;strong&gt;—Abort&lt;/strong&gt;: If a transaction aborts, changes made to the database are not visible. &lt;br&gt;
&lt;strong&gt;—Commit&lt;/strong&gt;: If a transaction commits, changes made are visible. &lt;/p&gt;

&lt;p&gt;Consider the following transaction T consisting of T1 and T2: Transfer of 100 from account X to account Y.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl2k1gud6vsi32iid248a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl2k1gud6vsi32iid248a.png" alt="Image description" width="356" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consistency:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This means that integrity constraints must be maintained so that the database is consistent before and after the transaction. It refers to the correctness of a database. Referring to the example above, &lt;br&gt;
The total amount before and after the transaction must be maintained. &lt;br&gt;
Total before &lt;strong&gt;T&lt;/strong&gt; occurs = &lt;strong&gt;500 + 200 = 700&lt;/strong&gt;. &lt;br&gt;
Total after &lt;strong&gt;T&lt;/strong&gt; occurs = &lt;strong&gt;400 + 300 = 700&lt;/strong&gt;. &lt;br&gt;
Therefore, the database is consistent. Inconsistency occurs in case &lt;strong&gt;T1&lt;/strong&gt; completes but &lt;strong&gt;T2&lt;/strong&gt; fails. As a result, &lt;strong&gt;T&lt;/strong&gt; is incomplete. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Isolation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This property ensures that multiple transactions can occur concurrently without leading to the inconsistency of the database state.&lt;/p&gt;

&lt;p&gt;Let X= 500, Y = 500. &lt;br&gt;
Consider two transactions T and T”. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxg8qn7lka1rzao8vuka2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxg8qn7lka1rzao8vuka2.png" alt="Image description" width="300" height="137"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Suppose T has been executed till Read (Y) and then T’’ starts. As a result, interleaving of operations takes place due to which T’’ reads the correct value of X but the incorrect value of Y and sum computed by &lt;br&gt;
T’’: (X+Y = 50, 000+500=50, 500) &lt;br&gt;
is thus not consistent with the sum at end of the transaction: &lt;br&gt;
T: (X+Y = 50, 000 + 450 = 50, 450). &lt;br&gt;
This results in database inconsistency, due to a loss of 50 units. Hence, transactions must take place in isolation and changes should be visible only after they have been made to the main memory. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Durability:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This property ensures that once the transaction has completed execution, the updates and modifications to the database are stored in and written to disk and they persist even if a system failure occurs. These updates now become permanent and are stored in non-volatile memory. The effects of the transaction, thus, are never lost. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages of ACID Properties in DBMS:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Data Consistency:&lt;/strong&gt; ACID properties ensure that the data remains consistent and accurate after any transaction execution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Integrity:&lt;/strong&gt; ACID properties maintain the integrity of the data by ensuring that any changes to the database are permanent and cannot be lost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Concurrency Control:&lt;/strong&gt; ACID properties help to manage multiple transactions occurring concurrently by preventing interference between them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recovery:&lt;/strong&gt; ACID properties ensure that in case of any failure or crash, the system can recover the data up to the point of failure or crash.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages of ACID Properties in DBMS:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Performance:&lt;/strong&gt; The ACID properties can cause a performance overhead in the system, as they require additional processing to ensure data consistency and integrity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability:&lt;/strong&gt; The ACID properties may cause scalability issues in large distributed systems where multiple transactions occur concurrently.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Complexity:&lt;/strong&gt; Implementing the ACID properties can increase the complexity of the system and require significant expertise and resources. Overall, the advantages of ACID properties in DBMS outweigh the disadvantages. They provide a reliable and consistent approach to data&lt;/li&gt;
&lt;li&gt;management, ensuring data integrity, accuracy, and reliability. However, in some cases, the overhead of implementing ACID properties can cause performance and scalability issues. Therefore, it’s important to balance the benefits of ACID properties against the specific needs and requirements of the system.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>database</category>
      <category>relationaldatabase</category>
      <category>mysql</category>
      <category>postgres</category>
    </item>
  </channel>
</rss>
