<?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: Danilsa Caraballo</title>
    <description>The latest articles on DEV Community by Danilsa Caraballo (@danilsa0109).</description>
    <link>https://dev.to/danilsa0109</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%2F680661%2F3e1abfc6-2600-48c2-bf71-223157e5c57c.jpg</url>
      <title>DEV Community: Danilsa Caraballo</title>
      <link>https://dev.to/danilsa0109</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/danilsa0109"/>
    <language>en</language>
    <item>
      <title>SQL: How to consult the database.</title>
      <dc:creator>Danilsa Caraballo</dc:creator>
      <pubDate>Wed, 27 Oct 2021 15:25:13 +0000</pubDate>
      <link>https://dev.to/danilsa0109/sql-how-to-consult-the-database-6p9</link>
      <guid>https://dev.to/danilsa0109/sql-how-to-consult-the-database-6p9</guid>
      <description>&lt;p&gt;We will  first remember the basic structure  of one &lt;a href="https://dev.to/danilsa0109/sqlite-a-tool-that-allows-creating-databases-from-the-terminal-78j"&gt;SQL table&lt;/a&gt;, to show you some ways to call the information of the table .&lt;/p&gt;

&lt;p&gt;I will start by summarizing the basics conventions that make up the declarations that we will be using  throughout this post.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Convention&lt;/th&gt;
&lt;th&gt;Used for&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CAPITAL LETTER&lt;/td&gt;
&lt;td&gt;keyword and data types&lt;/td&gt;
&lt;td&gt;SELECT, FROM, WHERE, OR, AND.TEXT, INTEGER, REAL.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;lower case&lt;/td&gt;
&lt;td&gt;Parameters given by the user&lt;/td&gt;
&lt;td&gt;nametable, name_column, etc.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;*&lt;/td&gt;
&lt;td&gt;Select the whole table&lt;/td&gt;
&lt;td&gt;All columns separated by rows:&lt;code&gt;[{ name_column_N : ’row content’ ,name_column_N+1 : ’row content’} , { name_column_N : ’row content’ , name_column_N+1 : ’row content’ }]&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a &amp;lt;&amp;gt; b&lt;/td&gt;
&lt;td&gt;Mathematical conditional called function&lt;/td&gt;
&lt;td&gt;a different to b&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a &amp;gt; b&lt;/td&gt;
&lt;td&gt;Mathematical conditional called function&lt;/td&gt;
&lt;td&gt;a greater than b&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a &amp;lt; b&lt;/td&gt;
&lt;td&gt;Mathematical conditional called function&lt;/td&gt;
&lt;td&gt;a less than b&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;n = c&lt;/td&gt;
&lt;td&gt;Mathematical conditional called function&lt;/td&gt;
&lt;td&gt;n same as c&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;n != c&lt;/td&gt;
&lt;td&gt;Mathematical conditional called function&lt;/td&gt;
&lt;td&gt;n different to c&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Example database:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The table will be called “colombia” , this columns is: “departamento” , “capital_departamento” and  “extencion_geografica_km2”. the columns is type text.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~ CREATE TABLE colombia (departament TEXT, departament_capital TEXT, geographic_extent_km2 INTEGRAL);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To the previous table, we enter department with their capital cities:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~ INSERT INTO colombia (departament, departament_capital, geographic_extent_km2) VALUES ('Antioquia','Medellín',63612 );

~ INSERT INTO colombia (departament, departament_capital, geographic_extent_km2) VALUES ('Bolívar','Cartagena', 25978 );

~ INSERT INTO colombia (departament, departament_capital, geographic_extent_km2) VALUES ('Valle del cauca','Cali', 22195);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Starting from the previous table, we make to query of diverse forms:&lt;/p&gt;

&lt;p&gt;note: for the view, before selecting, enter the command&lt;br&gt;
&lt;code&gt;~ .mode table;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To query the whole table:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;~ SELECT * FROM colombia ;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| departament    | departament_capital  | geographic_extent_km2 |
| -------------- |----------------------|-----------------------|
| Antioquia      | Medellin             |                  63612|
| Bolívar        | Cartagena            |                  25978|
| Valle del cauca| Cali                 |                  22195|

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To query a column in special:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;~ SELECT departament FROM colombia ;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| departament    |
| -------------- |
| Antioquia      |
| Bolívar        |
| Valle del cauca|
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To query a several columns:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;~ SELECT departament, departament_capital FROM colombia ;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| departament    | departament_capital  |
| -------------- |----------------------|
| Antioquia      | Medellin             |
| Bolívar        | Cartagena            |
| Valle del cauca| Cali                 |

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To query a column or several columns, where the row has a special conditional:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;~ SELECT departament FROM colombia WHERE departament_capital = 'Medellín' ;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| departament    |
| -------------- |
| Antioquia      |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;~ SELECT departament, departament_capital FROM colombia WHERE geographic_extent_km2 = 63612 ;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| departament    | departament_capital  |
| -------------- |----------------------|
| Antioquia      | Medellin             |

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;~ SELECT departament, departament_capital FROM colombia WHERE departament_capital &amp;lt;&amp;gt; 'Medellín';&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| departament    | departament_capital  |
| -------------- |----------------------|
| Bolívar        | Cartagena            |
| Valle del cauca| Cali                 |

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;~ SELECT departament, geographic_extent_km2 FROM colombia WHERE departament_capital != 'Cartagena';&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| departament    | geographic_extent_km2 |
| -------------- |-----------------------|
| Antioquia      |                  63612|
| Valle del cauca|                  22195|

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;~ SELECT departament, departament_capital FROM colombia WHERE geographic_extent_km2 &amp;lt; 26000;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| departament    | departament_capital  |
| -------------- |----------------------|
| Bolívar        | Cartagena            |
| Valle del cauca| Cali                 |

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;~ SELECT departament, departament_capital FROM colombia WHERE geographic_extent_km2 &amp;gt; 26000;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| departament    | departament_capital  |
| -------------- |----------------------|
| Antioquia      | Medellin             |

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>sql</category>
      <category>term</category>
      <category>database</category>
      <category>crud</category>
    </item>
    <item>
      <title>DELETE on SQL</title>
      <dc:creator>Danilsa Caraballo</dc:creator>
      <pubDate>Wed, 27 Oct 2021 15:19:20 +0000</pubDate>
      <link>https://dev.to/danilsa0109/delete-on-sql-gbg</link>
      <guid>https://dev.to/danilsa0109/delete-on-sql-gbg</guid>
      <description>&lt;p&gt;When a row is deleted from the database, using in the restriction the id attribute, whose value is unique. However, all also it’s possible using in the restriction others attributes or columns  with specific value, eg:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~ DELETE FROM friends WHERE name = 'Danil' OR name = 'Gracia';&lt;/code&gt;&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>sql</category>
      <category>database</category>
      <category>crud</category>
    </item>
    <item>
      <title>SQLite: A tool that allows creating databases from the terminal</title>
      <dc:creator>Danilsa Caraballo</dc:creator>
      <pubDate>Fri, 06 Aug 2021 14:43:05 +0000</pubDate>
      <link>https://dev.to/danilsa0109/sqlite-a-tool-that-allows-creating-databases-from-the-terminal-78j</link>
      <guid>https://dev.to/danilsa0109/sqlite-a-tool-that-allows-creating-databases-from-the-terminal-78j</guid>
      <description>&lt;p&gt;I had learned how to create a table for a new database using tools like Excel, Matlab, My sql and table plus.&lt;/p&gt;

&lt;p&gt;Now, with &lt;code&gt;SQLite&lt;/code&gt; I can create the databases in a very practical way, it is similar to &lt;code&gt;Mysql&lt;/code&gt;, so today I a practical example, comparing &lt;code&gt;Mysql&lt;/code&gt; with &lt;code&gt;SQLite&lt;/code&gt;,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We must be in the folder where we will create the database:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To &lt;code&gt;SQLite&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcn0e16op9ytt6ow195ha.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcn0e16op9ytt6ow195ha.png" alt="Alt Text" width="718" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;in the case of &lt;code&gt;Mysql&lt;/code&gt;, you must find the location of the program to be able to execute it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew search mysql
//or
./mysql -u root -p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Open the tool, giving name to database:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To &lt;code&gt;SQLite&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;~ sqlite3 mydatabase
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in the case of &lt;code&gt;Mysql&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~ create database mydatabase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create new table, taking into account the type of the column:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;SQLite&lt;/code&gt; and &lt;code&gt;Mysql&lt;/code&gt; are the same&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~ use mydatabase
~ create table dataUsers(
          Id integer primary key,
          Name text,
          Last_name text,
          age integer,
          Cell integer 
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;insert the data:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;SQLite&lt;/code&gt; and&lt;code&gt;Mysql&lt;/code&gt; are the same&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;insert into dataUsers(0001,'Ema','Garces', 21, 0573033333055 );

//or

insert into dataUsers( Name text,Last_name text, age real, Cell integer ) VALUES (0001,'Ema','Garces', 21, 0573033333055);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Show table:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To &lt;code&gt;SQLite&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~ .mode {mode of choice}
~ select * from dataUsers; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;there are several view modes to display the table:&lt;br&gt;
ascii, box, csv, column, html, insert, line, list, tabs, tcl, etc.&lt;/p&gt;

&lt;p&gt;in the case of &lt;code&gt;Mysql&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~ show tables;
~ describe dataUsers;
~ select * from dataUsers; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Bonus: Connect to database with table plus&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;6.1 open table plus:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvt87wz16b9dfm9ciao33.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvt87wz16b9dfm9ciao33.png" alt="Alt Text" width="499" height="637"&gt;&lt;/a&gt;&lt;br&gt;
6.2 create new connection:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzephts7lzwp4wdf8e531.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzephts7lzwp4wdf8e531.png" alt="Alt Text" width="525" height="328"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Febtrbb2rpmnegmwmu7ii.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Febtrbb2rpmnegmwmu7ii.png" alt="Alt Text" width="524" height="330"&gt;&lt;/a&gt;&lt;br&gt;
6.3 name the connection and find the location of the database:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fez76pif8qw90un2xkxl1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fez76pif8qw90un2xkxl1.png" alt="Alt Text" width="499" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
