<?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: Vera-778</title>
    <description>The latest articles on DEV Community by Vera-778 (@vera778).</description>
    <link>https://dev.to/vera778</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%2F1277923%2Fdb8b7af4-1490-4d83-ac2c-a1bfbf54df5b.png</url>
      <title>DEV Community: Vera-778</title>
      <link>https://dev.to/vera778</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vera778"/>
    <language>en</language>
    <item>
      <title>Class Inheritance</title>
      <dc:creator>Vera-778</dc:creator>
      <pubDate>Mon, 25 Mar 2024 07:47:10 +0000</pubDate>
      <link>https://dev.to/vera778/class-inheritance-3dii</link>
      <guid>https://dev.to/vera778/class-inheritance-3dii</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person:
    def __init__(self, first_name, last_name):
        self.first_name = first_name
        self.last_name = last_name
    def full_name(self):
        return self.first_name + ' ' + self.last_name
    def reverse_name(self):
        return self.last_name + ', ' + self.first_name

class Employee(Person): # Add Person to Employee in brackets, to make it a subclass of Person
    role = None
    def full_name_with_role(self): #add special attributes to the child class, in addition to the attributes get from parent class.
        return self.first_name + ' ' + self.last_name + ', ' + self.role
    def reverse_name(self): #override in child class
        return self.role + ', ' + self.first_name

x = Employee('John', 'Smith')
x.role = 'Director'
print(x.full_name_with_role())
print(x.reverse_name())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>beginners</category>
      <category>python</category>
    </item>
    <item>
      <title>Attributes can be instance</title>
      <dc:creator>Vera-778</dc:creator>
      <pubDate>Mon, 25 Mar 2024 02:33:02 +0000</pubDate>
      <link>https://dev.to/vera778/attributes-can-be-instance-2bc1</link>
      <guid>https://dev.to/vera778/attributes-can-be-instance-2bc1</guid>
      <description>&lt;p&gt;An attribute of an object can be an instance of another class, or perhaps even the same class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;basil = Person('Basil', 'Fawlty') #basil is an instance here
polly = Person('Polly', 'Sherman', basil) # basil is an attribute of boss of polly here
print(polly.boss.full_name()) #Basil Fawlty

class Person:
    def __init__(self, first_name, last_name, boss = None):
        self.first_name = first_name
        self.last_name = last_name
        self.boss = boss
    def full_name(self):
        return self.first_name + ' ' + self.last_name
    def reverse_name(self):
        return self.last_name + ', ' + self.first_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Instance Attributes &amp; Class Attributes</title>
      <dc:creator>Vera-778</dc:creator>
      <pubDate>Mon, 25 Mar 2024 02:17:49 +0000</pubDate>
      <link>https://dev.to/vera778/instance-attributes-class-attributes-4hc5</link>
      <guid>https://dev.to/vera778/instance-attributes-class-attributes-4hc5</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Square:
    def __init__(self, side):
        self.side = side
    def area(self): # self parameter - this is an instance method
        return self.side ** 2
    def calculate_area(side): # No self parameter - this is a class method 
        return side ** 2

sq = Square(10) # Create an instance
print(sq.area()) # Invoke an instance method
print(Square.calculate_area(20)) # Invoke a class method
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The method can be invoked by using the class name and the method name. It provides a way of organising methods that are related to the class, but do not belong on the instances themselves.&lt;/p&gt;

&lt;p&gt;If the attribute is a field then you can make it a class field by defining it outside the constructor. It will be then shared by all class instances. it represents a characteristic of the entire class rather than individual objects. Class fields have a single value shared by all instances. Hence changing the value impacts all instances equally as shown in the example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Square:
    nbInstances = 0
    def __init__(self, side):
        self.side = side
        Square.nbInstances += 1
    def area(self): # self parameter - this is an instance method
        return self.side ** 2
    def calculate_area(side): # No self parameter - this is a class method 
        return side ** 2

sq = Square(10) # Create an instance
print(sq.area()) # Invoke an instance method
print(Square.calculate_area(20)) # Invoke a class method
print(Square.nbInstances) # Outputs 1
print(sq.nbInstances) # Outputs 1
sq2 = Square(10) # Create another instance
print(Square.nbInstances) # Outputs 2
print(sq.nbInstances) # Outputs 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>beginners</category>
    </item>
    <item>
      <title>Some Special Methods in Python Class</title>
      <dc:creator>Vera-778</dc:creator>
      <pubDate>Mon, 25 Mar 2024 01:59:24 +0000</pubDate>
      <link>https://dev.to/vera778/some-special-methods-in-python-class-34hl</link>
      <guid>https://dev.to/vera778/some-special-methods-in-python-class-34hl</guid>
      <description>&lt;p&gt;class Square:&lt;br&gt;
    def &lt;strong&gt;init&lt;/strong&gt;(self, side):&lt;br&gt;
        self.side = side&lt;br&gt;
    def &lt;strong&gt;eq&lt;/strong&gt;(self, other):&lt;br&gt;
        return self.side == other.side&lt;br&gt;
    def &lt;strong&gt;ne&lt;/strong&gt;(self, other):&lt;br&gt;
        return self.side != other.side&lt;br&gt;&lt;br&gt;
    def &lt;strong&gt;lt&lt;/strong&gt;(self, other):&lt;br&gt;
        return self.side &amp;lt; other.side&lt;br&gt;
    def &lt;strong&gt;le&lt;/strong&gt;(self, other):&lt;br&gt;
        return self.side &amp;lt;= other.side&lt;br&gt;
    def &lt;strong&gt;gt&lt;/strong&gt;(self, other):&lt;br&gt;
        return self.side &amp;gt; other.side&lt;br&gt;
    def &lt;strong&gt;ge&lt;/strong&gt;(self, other):&lt;br&gt;
        return self.side &amp;gt;= other.side&lt;/p&gt;

&lt;p&gt;sq1 = Square(10)&lt;br&gt;
sq2 = Square(11)&lt;br&gt;
print(sq1 != sq2)&lt;br&gt;
print(sq1 &amp;lt; sq2)&lt;br&gt;
print(sq1 &amp;lt;= sq2)&lt;br&gt;
print(sq1 &amp;gt; sq2)&lt;br&gt;
print(sq1 &amp;gt;= sq2)&lt;/p&gt;

&lt;p&gt;+: object.&lt;strong&gt;add&lt;/strong&gt;(self, other)&lt;br&gt;
-: object.&lt;strong&gt;sub&lt;/strong&gt;(self, other)&lt;br&gt;
&lt;em&gt;: object.&lt;strong&gt;mul&lt;/strong&gt;(self, other)&lt;br&gt;
/: object.&lt;strong&gt;div&lt;/strong&gt;(self, other)&lt;br&gt;
%: object.&lt;strong&gt;mod&lt;/strong&gt;(self, other)&lt;br&gt;
*&lt;/em&gt;: object.&lt;strong&gt;pow&lt;/strong&gt;(self, other)&lt;br&gt;
&amp;amp;: object.&lt;strong&gt;and&lt;/strong&gt;(self, other)&lt;br&gt;
^: object.&lt;strong&gt;xor&lt;/strong&gt;(self, other)&lt;br&gt;
|: object.&lt;strong&gt;or&lt;/strong&gt;(self, other)&lt;br&gt;
+=: object.&lt;strong&gt;iadd&lt;/strong&gt;(self, other) ("i" for in place)&lt;br&gt;
-=: object.&lt;strong&gt;isub&lt;/strong&gt;(self, other)&lt;br&gt;
&lt;em&gt;=: object.&lt;strong&gt;imul&lt;/strong&gt;(self, other)&lt;br&gt;
/=: object.&lt;strong&gt;idiv&lt;/strong&gt;(self, other)&lt;br&gt;
%=: object.&lt;strong&gt;imod&lt;/strong&gt;(self, other)&lt;br&gt;
*&lt;/em&gt;=: object.&lt;strong&gt;ipow&lt;/strong&gt;(self, other)&lt;br&gt;
-: object.&lt;strong&gt;neg&lt;/strong&gt;(self)&lt;br&gt;
+: object.&lt;strong&gt;pos&lt;/strong&gt;(self)&lt;br&gt;
abs(): object.&lt;strong&gt;abs&lt;/strong&gt;(self)&lt;br&gt;
int(): object.&lt;strong&gt;int&lt;/strong&gt;(self)&lt;br&gt;
float(): object.&lt;strong&gt;float&lt;/strong&gt;(self)&lt;/p&gt;

</description>
      <category>beginners</category>
    </item>
    <item>
      <title>Date and Time in Python</title>
      <dc:creator>Vera-778</dc:creator>
      <pubDate>Tue, 20 Feb 2024 03:53:09 +0000</pubDate>
      <link>https://dev.to/vera778/date-and-time-in-python-28lb</link>
      <guid>https://dev.to/vera778/date-and-time-in-python-28lb</guid>
      <description>&lt;p&gt;When working with real-world data you often have to deal with dates and times. Date and times can be tricky to work with, because people format and present them in different ways. Consider, for example, a date written as "02-03-1998". Does this represent 2nd March 1998, or 3rd February 1998? In Australia it would be the former, but in the US it would be the latter.&lt;/p&gt;

&lt;p&gt;Python has a datetime library that defines datetime , date, and time types. These provide a uniform and comprehensive way to handle dates and times. The datetime type is the most flexible and thus the most commonly used. There is also a timedelta type, which is used to work with durations (i.e., time intervals).&lt;/p&gt;

&lt;p&gt;To use these you need to import them:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from datetime import datetime, date, time, timedelta&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You don't need to import them all - just the ones you will be using.&lt;/p&gt;

&lt;p&gt;Usually your goal will be to convert a string or integer representation of a date or time into a datetime object, apply whatever processing you need to the object, and then use a formatting function to convert it back to a traditional format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating a datetime object&lt;/strong&gt;&lt;br&gt;
There are several ways to create a datetime object.&lt;/p&gt;

&lt;p&gt;You can directly construct it by providing the year, month, and day, and, optionally, the time and timezone.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from datetime import datetime&lt;br&gt;
dt = datetime(&lt;br&gt;
    year = 1968, month = 6, day = 24,&lt;br&gt;
    hour = 5, minute = 30, second = 0&lt;br&gt;
)&lt;br&gt;
print(dt)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can also construct it from a string. In this case you need to tell Python what format the string uses:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from datetime import datetime&lt;br&gt;
dt = datetime.strptime('24-06-1968, 05:30:00', '%d-%m-%Y, %H:%M:%S')&lt;br&gt;
print(dt)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The trickiest part about this is remembering what the formatting codes are. You'll probably find yourself looking them up quite often. Here are the main ones:&lt;/p&gt;

&lt;p&gt;%Y Four-digit year (1968)&lt;br&gt;
%y Two-digit year (68)&lt;/p&gt;

&lt;p&gt;%B Full month name (June)&lt;br&gt;
%b Abbreviated month name (Jun)&lt;br&gt;
%m Two-digit month number (01-12)&lt;/p&gt;

&lt;p&gt;%A Full day name (Monday)&lt;br&gt;
%a Abbreviated day name (Mon)&lt;br&gt;
%d Two-digit day number (01-31)&lt;/p&gt;

&lt;p&gt;%H Two-digit hour (00-23)&lt;br&gt;
%I Two-digit hour (00-12)&lt;/p&gt;

&lt;p&gt;%M Two-digit minute (00-59)&lt;br&gt;
%S Two-digit second (00-59)&lt;/p&gt;

&lt;p&gt;%p AM/PM&lt;/p&gt;

&lt;p&gt;If you want a datetime object that represents the current date and time you can use the now method:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from datetime import datetime&lt;br&gt;
dt = datetime.now()&lt;br&gt;
print(dt)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unix timestamp&lt;/strong&gt;&lt;br&gt;
You can also construct a datetime object from a Unix timestamp. This is one of the most common representations of time.  It represents the time as a numerical value - the number of seconds since the Unix epoch, which was at 00:00:00 on Thursday, 1 January 1970 UTC. You can get the current Unix timestamp using the time.time function.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from time import time&lt;br&gt;
print(time())&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To create a datetime object from a Unix timestamp you can use use datetime.fromtimestamp().&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from datetime import datetime&lt;br&gt;
x = datetime.fromtimestamp(1565315907)&lt;br&gt;
print(x)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extracting the components of a datetime object&lt;/strong&gt;&lt;br&gt;
Once you have a datetime object you can extract its individual components:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from datetime import datetime&lt;br&gt;
dt = datetime(&lt;br&gt;
    year = 1968, month = 6, day = 24,&lt;br&gt;
    hour = 5, minute = 30, second = 0&lt;br&gt;
)&lt;br&gt;
print(dt.year)&lt;br&gt;
print(dt.month)&lt;br&gt;
print(dt.day)&lt;br&gt;
print(dt.hour)&lt;br&gt;
print(dt.minute)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can also extract a date object or a time object from a datetime object:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from datetime import datetime&lt;br&gt;
dt = datetime(&lt;br&gt;
    year = 1968, month = 6, day = 24,&lt;br&gt;
    hour = 5, minute = 30, second = 0&lt;br&gt;
)&lt;br&gt;
print(dt.date())&lt;br&gt;
print(dt.time())&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Formatting a datetime object as a string&lt;/strong&gt;&lt;br&gt;
A very common thing to do is to present a datetime object in a certain format. You can use the strftime method, to do this. You need to specify the format you would like, using the same formatting codes as listed above.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from datetime import datetime&lt;br&gt;
dt = datetime(&lt;br&gt;
    year = 1968, month = 6, day = 24,&lt;br&gt;
    hour = 5, minute = 30, second = 0&lt;br&gt;
)&lt;br&gt;
print(dt.strftime('%d %B %Y, at %I:%M %p'))&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operating on datetime objects&lt;/strong&gt;&lt;br&gt;
One of the most useful features of datetime objects is that you can very easily calculate new dates and times. The datetime module is so nicely designed that the following examples should be self-explanatory:&lt;/p&gt;

&lt;p&gt;First example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from datetime import datetime, timedelta&lt;br&gt;
now = datetime.now()&lt;br&gt;
print(now + timedelta(hours=1))&lt;br&gt;
print(now + timedelta(days=1))&lt;br&gt;
print(now - timedelta(weeks=2))&lt;br&gt;
print(now + timedelta(weeks=4, days=3, hours=2, seconds=45))&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Second example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from datetime import datetime, timedelta&lt;br&gt;
new_years_eve = datetime(year=2024, month=12, day=31)&lt;br&gt;
now = datetime.now()&lt;br&gt;
time_remaining = new_years_eve - now&lt;br&gt;
print(time_remaining)&lt;/code&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
    </item>
    <item>
      <title>The Past, Present, and Future of Database Technology</title>
      <dc:creator>Vera-778</dc:creator>
      <pubDate>Tue, 13 Feb 2024 07:23:36 +0000</pubDate>
      <link>https://dev.to/vera778/the-past-present-and-future-of-database-technology-29o7</link>
      <guid>https://dev.to/vera778/the-past-present-and-future-of-database-technology-29o7</guid>
      <description>&lt;p&gt;&lt;strong&gt;Past:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Relational Databases (1970s - 1990s):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The past of database technology is characterized by the dominance of relational databases. Pioneered by Edgar F. Codd in the 1970s, relational databases, such as IBM's DB2, Oracle, and Microsoft SQL Server, became the standard for managing structured data. SQL (Structured Query Language) emerged as the standard language for interacting with relational databases.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Client-Server Architecture:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the 1980s and 1990s, client-server architectures became prevalent. Database servers served as centralized repositories for data, and client applications interacted with these servers to retrieve and manipulate data. This architecture improved scalability and allowed for distributed computing.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Normalization and Data Integrity:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The emphasis on normalization techniques to reduce redundancy and improve data integrity became a fundamental principle in database design during this period. Database management systems (DBMS) focused on enforcing data integrity through constraints and normalization rules.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Big Data and NoSQL (2000s - Present):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The present era has seen the emergence of big data technologies and NoSQL databases. With the rise of web applications and the need to handle large volumes of unstructured or semi-structured data, NoSQL databases like MongoDB, Cassandra, and Couchbase gained popularity. These databases provide flexibility and scalability for handling diverse data types and large datasets.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cloud-Based Databases:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cloud computing has significantly influenced database technology. Cloud-based databases, offered by providers like Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform, enable organizations to scale their database infrastructure dynamically, pay for usage, and leverage managed services for database administration.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Polyglot Persistence:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The concept of polyglot persistence acknowledges that different types of data are best suited for different database models. Organizations often use a mix of relational and NoSQL databases based on the nature of their data and specific use cases.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;In-Memory Databases:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In-memory databases, such as SAP HANA and Redis, have gained popularity for their ability to store and retrieve data directly from RAM, leading to significant performance improvements. This is particularly valuable for applications requiring low-latency access to data.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Machine Learning and AI Integration:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The future of database technology is likely to involve tighter integration with machine learning and artificial intelligence. Databases may incorporate AI-driven features for query optimization, data analysis, and automated decision-making processes.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Blockchain and Distributed Ledgers:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blockchain technology and distributed ledger systems are gaining attention for their potential impact on databases. These technologies offer decentralized, secure, and tamper-proof methods for recording and verifying transactions, which could have implications for data integrity and trust.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Serverless Databases:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Serverless database architectures, where infrastructure management is abstracted away, are becoming more prevalent. Serverless databases can automatically scale based on demand, offering cost-efficiency and simplicity for developers.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Graph Databases:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Graph databases, designed to handle relationships efficiently, are expected to play a more significant role, especially in applications involving social networks, fraud detection, and recommendation systems.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Continued Evolution of NoSQL:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The NoSQL landscape will likely continue to evolve, with new databases emerging to address specific use cases and challenges. Features such as multi-model databases, combining graph, document, and key-value stores, may become more common.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Edge Databases:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With the growth of edge computing, databases optimized for edge environments, where data is processed closer to the source, may become more prevalent. These databases will address the challenges of latency and connectivity in distributed and edge computing scenarios.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>beginners</category>
    </item>
    <item>
      <title>Transactions and Concurrency Control</title>
      <dc:creator>Vera-778</dc:creator>
      <pubDate>Tue, 13 Feb 2024 07:02:13 +0000</pubDate>
      <link>https://dev.to/vera778/transactions-and-concurrency-control-108f</link>
      <guid>https://dev.to/vera778/transactions-and-concurrency-control-108f</guid>
      <description>&lt;p&gt;&lt;strong&gt;Transactions:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A transaction is a sequence of one or more operations on a database that is executed as a single unit of work. The primary goal of transactions is to maintain the consistency and integrity of the database even in the presence of failures. Transactions adhere to the ACID properties:&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Atomicity ensures that a transaction is treated as a single, indivisible unit of work. Either all the changes made by the transaction are committed to the database, or none of them are. If any part of the transaction fails, the entire transaction is rolled back.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Consistency:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Consistency ensures that a transaction brings the database from one valid state to another. The database should always be in a consistent state, meaning it adheres to the defined integrity constraints and business rules.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Isolation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Isolation ensures that the execution of one transaction is isolated from the execution of other transactions. Even if multiple transactions are executed concurrently, each should see the database as if it is the only transaction in progress. Isolation levels (e.g., Read Uncommitted, Read Committed, Repeatable Read, Serializable) define the degree of isolation.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Durability:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Durability guarantees that once a transaction is committed, its effects will persist even in the face of system failures. The changes made by committed transactions are permanently stored in the database.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Concurrency Control:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Concurrency control is a mechanism used to manage the simultaneous execution of multiple transactions in a way that maintains the consistency of the database. It addresses issues that can arise when multiple transactions are executed concurrently, such as lost updates, uncommitted data, and inconsistent reads. Key concepts and techniques in concurrency control include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Locking:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Locking is a common technique used to control access to data. Transactions acquire locks on data items, preventing other transactions from accessing or modifying the same data simultaneously. There are different types of locks, such as read locks and write locks.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Isolation Levels:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Isolation levels define the degree to which one transaction is isolated from the effects of other concurrently executing transactions. Common isolation levels include Read Uncommitted, Read Committed, Repeatable Read, and Serializable. Higher isolation levels provide stronger guarantees but may lead to more contention.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Serializability:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Serializability ensures that the execution of a set of concurrent transactions is equivalent to some serial execution of those transactions. In other words, the final result is as if transactions were executed one after another, even though they may execute concurrently.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Timestamp Ordering:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Timestamp ordering uses timestamps to order transactions and their operations. Transactions are assigned timestamps, and the system ensures that transactions are executed in timestamp order. This helps maintain a consistent and predictable order of transactions.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Two-Phase Locking (2PL):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Two-Phase Locking is a concurrency control protocol that ensures transactions follow a set of rules regarding acquiring and releasing locks. The protocol has two phases: the growing phase, where locks can be acquired, and the shrinking phase, where locks can only be released.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Optimistic Concurrency Control:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Optimistic Concurrency Control assumes that conflicts between transactions are rare. Instead of locking data, it allows transactions to proceed without interference and checks for conflicts only at the end of the transaction. If conflicts are detected, appropriate actions are taken.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Multiversion Concurrency Control (MVCC):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MVCC maintains multiple versions of a data item to allow concurrent transactions to read and modify the data without blocking each other. Each transaction sees a snapshot of the database at a specific point in time.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Concurrency control is crucial in a multi-user database environment where multiple transactions may try to access and modify data simultaneously. By ensuring that transactions are executed in a controlled manner, concurrency control mechanisms help prevent data inconsistencies and maintain the integrity of the database.&lt;/p&gt;

</description>
      <category>beginners</category>
    </item>
    <item>
      <title>Why Study Databases</title>
      <dc:creator>Vera-778</dc:creator>
      <pubDate>Tue, 13 Feb 2024 03:08:35 +0000</pubDate>
      <link>https://dev.to/vera778/why-study-databases-1736</link>
      <guid>https://dev.to/vera778/why-study-databases-1736</guid>
      <description>&lt;p&gt;1.&lt;strong&gt;Databases touch all aspects of our lives.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data will always have to be: stored, manipulated/accessed, shared, and transmitted. We can define database as a collection of related data that models some aspect of the real world. Also, databases are the core component of most computer applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2.&lt;strong&gt;Using file systems as data management has draw backs. Database systems offer solutions.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Data redundancy and inconsistency.&lt;/em&gt; There might be dupliction of information in different files. And the files would have multiple formats.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Difficulty in accessing data.&lt;/em&gt; There is always a new program needed to carry out a new task.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Integrity problems.&lt;/em&gt; Intergrity constraints might be unnoticed, while in databases, they'll be clearly kept and stated. Also, it's hard to add/mordify constraints in file system. (need to be understanded by practise)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Data isolation.&lt;/em&gt; Which is obvious.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Atomicity of updates.&lt;/em&gt; Not quiet understand.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Hard to allow concurrent access by multiple users.&lt;/em&gt; Uncontrolled concurrent accesses can lead to inconsistencies.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3.&lt;strong&gt;The field of databases&lt;/strong&gt; deals with data, relationships, constraints, redundancy, data manipulation, transactions, concurrency, and scale. I'll find out exactly what they mean later.&lt;/p&gt;

&lt;p&gt;4.&lt;strong&gt;About Data&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;According to Elmasri/Navathe, data are &lt;strong&gt;known facts&lt;/strong&gt; that can be recorded. There are two types of Data, one is unstructured, the other is structured.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5.&lt;strong&gt;About Database&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Database is a collection of related and structured data. Data items alone are relatively useless.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Database Management&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;DBMS(Database Management System): Which manipulate and maintain databases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Database system: Database + DBMS.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Database Users&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DBAs(Database Administrator), Application Programmers, and End Users.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Design a Database&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Conceptual Design: Requirements can be represented and manipulated using some computerized tools so that it can be easily maintained, modified, and transformed into a database implementation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Logical Design: Translated by conceptual design that can be expressed in a data model implemented in a DBMS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Physical Design: Further specifications are provided for storing and accessing the database.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;6.&lt;strong&gt;RDBMS(Relational DBMS)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Data Model&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Definition: concepts used to describe the allowed structure of a database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Levels of DM: High-level or conceptual (ER model for example), implementation or record-based, andd low-level or physical.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Database Schema&lt;/strong&gt;: a formalism of the data model, the structual description of what information will database hold.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Database instance&lt;/strong&gt;: any conbination of actual information populated in the database at a particular time.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
    </item>
    <item>
      <title>How to use stored procedures and triggers to extend DBMS capabilities</title>
      <dc:creator>Vera-778</dc:creator>
      <pubDate>Sun, 11 Feb 2024 03:14:13 +0000</pubDate>
      <link>https://dev.to/vera778/how-to-use-stored-procedures-and-triggers-to-extend-dbms-capabilities-j95</link>
      <guid>https://dev.to/vera778/how-to-use-stored-procedures-and-triggers-to-extend-dbms-capabilities-j95</guid>
      <description>&lt;p&gt;Stored procedures and triggers are database objects that can be used to extend the capabilities of a Database Management System (DBMS). They provide a way to encapsulate business logic, automate tasks, and enforce data integrity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stored Procedures:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a Stored Procedure:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Use the &lt;code&gt;CREATE PROCEDURE&lt;/code&gt; statement to define a stored procedure. It can include input parameters, output parameters, and a set of SQL statements.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;DELIMITER&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt;
   &lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;PROCEDURE&lt;/span&gt; &lt;span class="n"&gt;sp_example&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="n"&gt;parameter1&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;OUT&lt;/span&gt; &lt;span class="n"&gt;result1&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="k"&gt;BEGIN&lt;/span&gt;
       &lt;span class="c1"&gt;-- SQL statements&lt;/span&gt;
   &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt;
   &lt;span class="k"&gt;DELIMITER&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Call a Stored Procedure:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Use the &lt;code&gt;CALL&lt;/code&gt; statement to execute a stored procedure.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;CALL&lt;/span&gt; &lt;span class="n"&gt;sp_example&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="k"&gt;output&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Input and Output Parameters:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Define input parameters using &lt;code&gt;IN&lt;/code&gt; and output parameters using &lt;code&gt;OUT&lt;/code&gt;. Parameters allow you to pass values into and out of the stored procedure.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Triggers:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a Trigger:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Use the &lt;code&gt;CREATE TRIGGER&lt;/code&gt; statement to define a trigger. A trigger is associated with a specific table and is executed automatically when a specific event (e.g., INSERT, UPDATE, DELETE) occurs on that table.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;DELIMITER&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt;
   &lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TRIGGER&lt;/span&gt; &lt;span class="n"&gt;tr_example&lt;/span&gt;
   &lt;span class="k"&gt;AFTER&lt;/span&gt; &lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt;
   &lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="k"&gt;EACH&lt;/span&gt; &lt;span class="k"&gt;ROW&lt;/span&gt;
   &lt;span class="k"&gt;BEGIN&lt;/span&gt;
       &lt;span class="c1"&gt;-- SQL statements&lt;/span&gt;
   &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt;
   &lt;span class="k"&gt;DELIMITER&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Trigger Events:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Specify the trigger event (INSERT, UPDATE, DELETE) and the timing (BEFORE or AFTER) using the &lt;code&gt;BEFORE&lt;/code&gt; or &lt;code&gt;AFTER&lt;/code&gt; keywords.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Accessing Old and New Values:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;OLD&lt;/code&gt; and &lt;code&gt;NEW&lt;/code&gt; to reference the old and new values in the trigger body. This is especially useful in UPDATE triggers.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TRIGGER&lt;/span&gt; &lt;span class="n"&gt;tr_example&lt;/span&gt;
   &lt;span class="k"&gt;BEFORE&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt;
   &lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="k"&gt;EACH&lt;/span&gt; &lt;span class="k"&gt;ROW&lt;/span&gt;
   &lt;span class="k"&gt;BEGIN&lt;/span&gt;
       &lt;span class="c1"&gt;-- Access old and new values&lt;/span&gt;
       &lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;old_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;OLD&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column_name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
       &lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;new_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;NEW&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column_name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Enforce Data Integrity:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Triggers can be used to enforce data integrity by performing additional checks or actions when certain conditions are met.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TRIGGER&lt;/span&gt; &lt;span class="n"&gt;tr_check_balance&lt;/span&gt;
   &lt;span class="k"&gt;BEFORE&lt;/span&gt; &lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;transactions&lt;/span&gt;
   &lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="k"&gt;EACH&lt;/span&gt; &lt;span class="k"&gt;ROW&lt;/span&gt;
   &lt;span class="k"&gt;BEGIN&lt;/span&gt;
       &lt;span class="n"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;NEW&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;account_balance&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
           &lt;span class="n"&gt;SIGNAL&lt;/span&gt; &lt;span class="k"&gt;SQLSTATE&lt;/span&gt; &lt;span class="s1"&gt;'45000'&lt;/span&gt;
           &lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="k"&gt;MESSAGE_TEXT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Insufficient funds'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
       &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="n"&gt;IF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Drop a Trigger:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Use the &lt;code&gt;DROP TRIGGER&lt;/code&gt; statement to remove a trigger from the database.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;DROP&lt;/span&gt; &lt;span class="k"&gt;TRIGGER&lt;/span&gt; &lt;span class="n"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="n"&gt;tr_example&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>beginners</category>
    </item>
    <item>
      <title>Fundamental SQL concepts</title>
      <dc:creator>Vera-778</dc:creator>
      <pubDate>Sun, 11 Feb 2024 02:50:29 +0000</pubDate>
      <link>https://dev.to/vera778/fundamental-sql-concepts-2gdb</link>
      <guid>https://dev.to/vera778/fundamental-sql-concepts-2gdb</guid>
      <description>&lt;p&gt;Hi guys, this is the first day I learn IT (officially). I decide to take notes about whatever I think important and related. Hopefully I can form a network of knowledge one day. &lt;br&gt;
It would be so ideal if someone read my posts and help me improve. All suggestions are welcomed. Learning is detemined to be a road of loneliness, but one will go further with other lonely geeks. That's what I thought the meaning of communities.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;SELECT Statement:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;SELECT&lt;/code&gt; statement is used to retrieve data from one or more tables.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;column1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;column2&lt;/span&gt;
   &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. &lt;strong&gt;FROM Clause:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;FROM&lt;/code&gt; clause specifies the table or tables from which to retrieve data.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;column1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;column2&lt;/span&gt;
   &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. &lt;strong&gt;WHERE Clause:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;WHERE&lt;/code&gt; clause is used to filter rows based on specific conditions.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;column1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;column2&lt;/span&gt;
   &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt;
   &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. &lt;strong&gt;AND, OR, NOT Operators:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Combine conditions using &lt;code&gt;AND&lt;/code&gt;, &lt;code&gt;OR&lt;/code&gt;, and &lt;code&gt;NOT&lt;/code&gt; operators in the &lt;code&gt;WHERE&lt;/code&gt; clause.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;column1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;column2&lt;/span&gt;
   &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt;
   &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;condition1&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;condition2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. &lt;strong&gt;ORDER BY Clause:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;ORDER BY&lt;/code&gt; clause is used to sort the result set based on one or more columns.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;column1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;column2&lt;/span&gt;
   &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt;
   &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;column1&lt;/span&gt; &lt;span class="k"&gt;ASC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. &lt;strong&gt;INSERT INTO Statement:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;INSERT INTO&lt;/code&gt; statement is used to insert new records into a table.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;column1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;column2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7. &lt;strong&gt;UPDATE Statement:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;UPDATE&lt;/code&gt; statement is used to modify existing records in a table.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt;
   &lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;column1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;column2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value2&lt;/span&gt;
   &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8. &lt;strong&gt;DELETE Statement:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;DELETE&lt;/code&gt; statement is used to remove records from a table.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt;
   &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9. &lt;strong&gt;JOIN Clause:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;JOIN&lt;/code&gt; clause is used to combine rows from two or more tables based on a related column.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;column1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;column2&lt;/span&gt;
   &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;
   &lt;span class="k"&gt;INNER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10. &lt;strong&gt;GROUP BY Clause:&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- The `GROUP BY` clause is used to group rows based on one or more columns, often used with aggregate functions.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```sql
SELECT column1, COUNT(*)
FROM table_name
GROUP BY column1;
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  11. &lt;strong&gt;HAVING Clause:&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- The `HAVING` clause is used with the `GROUP BY` clause to filter the results based on aggregate values.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```sql
SELECT column1, COUNT(*)
FROM table_name
GROUP BY column1
HAVING COUNT(*) &amp;gt; 10;
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  12. &lt;strong&gt;Aliases:&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Use aliases to provide temporary names for columns or tables in your queries.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```sql
SELECT column1 AS alias1, column2 AS alias2
FROM table_name;
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  13. &lt;strong&gt;Comments:&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Use `--` for single-line comments or `/* */` for multi-line comments.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```sql
-- This is a single-line comment

/*
This is a
multi-line comment
*/
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>beginners</category>
    </item>
  </channel>
</rss>
