<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.wikijournal.org/w-wiki/index.php?action=history&amp;feed=atom&amp;title=Relational_databases_for_beginners</id>
	<title>Relational databases for beginners - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://en.wikijournal.org/w-wiki/index.php?action=history&amp;feed=atom&amp;title=Relational_databases_for_beginners"/>
	<link rel="alternate" type="text/html" href="https://en.wikijournal.org/w-wiki/index.php?title=Relational_databases_for_beginners&amp;action=history"/>
	<updated>2026-04-18T22:52:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://en.wikijournal.org/w-wiki/index.php?title=Relational_databases_for_beginners&amp;diff=1502&amp;oldid=prev</id>
		<title>Philip: Created page with &quot;== What is a Relational Database? == Imagine you are running an online store. You have information about customers, their orders, and products. How can you organize all this data? A relational database allows you to store information in related tables, similar to Excel spreadsheets, but much more powerful.  == Key Concepts ==  === Tables === Each table represents a specific entity. For example:  * Users table (users) * Orders table (orders) * Products table (products)  =...&quot;</title>
		<link rel="alternate" type="text/html" href="https://en.wikijournal.org/w-wiki/index.php?title=Relational_databases_for_beginners&amp;diff=1502&amp;oldid=prev"/>
		<updated>2025-01-15T22:17:21Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== What is a Relational Database? == Imagine you are running an online store. You have information about customers, their orders, and products. How can you organize all this data? A relational database allows you to store information in related tables, similar to Excel spreadsheets, but much more powerful.  == Key Concepts ==  === Tables === Each table represents a specific entity. For example:  * Users table (users) * Orders table (orders) * Products table (products)  =...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== What is a Relational Database? ==&lt;br /&gt;
Imagine you are running an online store. You have information about customers, their orders, and products. How can you organize all this data? A relational database allows you to store information in related tables, similar to Excel spreadsheets, but much more powerful.&lt;br /&gt;
&lt;br /&gt;
== Key Concepts ==&lt;br /&gt;
&lt;br /&gt;
=== Tables ===&lt;br /&gt;
Each table represents a specific entity. For example:&lt;br /&gt;
&lt;br /&gt;
* Users table (users)&lt;br /&gt;
* Orders table (orders)&lt;br /&gt;
* Products table (products)&lt;br /&gt;
&lt;br /&gt;
=== Fields (Columns) ===&lt;br /&gt;
Each table consists of fields. For example, for the users table, these could be:&lt;br /&gt;
&lt;br /&gt;
* id (unique identifier)&lt;br /&gt;
* name&lt;br /&gt;
* email&lt;br /&gt;
* phone&lt;br /&gt;
* registration date&lt;br /&gt;
&lt;br /&gt;
=== Records (Rows) ===&lt;br /&gt;
These are the actual data in a table. One row = one record about a user, an order, or a product.&lt;br /&gt;
&lt;br /&gt;
== How are Tables Related to Each Other? ==&lt;br /&gt;
&lt;br /&gt;
=== Primary Keys ===&lt;br /&gt;
Each table should have a unique identifier for each record. Typically, this is the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; field:&amp;lt;syntaxhighlight lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
CREATE TABLE users (&lt;br /&gt;
    id INT PRIMARY KEY AUTO_INCREMENT,&lt;br /&gt;
    name VARCHAR(100),&lt;br /&gt;
    email VARCHAR(100)&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Foreign Keys ===&lt;br /&gt;
These are fields that link one table to another. For example, in the orders table, we store the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; of the user:&amp;lt;syntaxhighlight lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
CREATE TABLE orders (&lt;br /&gt;
    id INT PRIMARY KEY AUTO_INCREMENT,&lt;br /&gt;
    user_id INT,&lt;br /&gt;
    order_date DATETIME,&lt;br /&gt;
    total_amount DECIMAL(10,2),&lt;br /&gt;
    FOREIGN KEY (user_id) REFERENCES users(id)&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Types of Relationships Between Tables ==&lt;br /&gt;
&lt;br /&gt;
=== One-to-One ===&lt;br /&gt;
For example, a user can have one profile with additional information:&amp;lt;syntaxhighlight lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
CREATE TABLE user_profiles (&lt;br /&gt;
    user_id INT PRIMARY KEY,&lt;br /&gt;
    address TEXT,&lt;br /&gt;
    phone VARCHAR(20),&lt;br /&gt;
    FOREIGN KEY (user_id) REFERENCES users(id)&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-to-Many ===&lt;br /&gt;
The most common type of relationship. For example, one user can have many orders:&lt;br /&gt;
&lt;br /&gt;
* One user → Many orders&lt;br /&gt;
* One product → Many reviews&lt;br /&gt;
* One category → Many products&lt;br /&gt;
&lt;br /&gt;
=== Many-to-Many ===&lt;br /&gt;
For example, one order can contain many products, and one product can appear in multiple orders. For this, an intermediate table is created:&amp;lt;syntaxhighlight lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
CREATE TABLE order_items (&lt;br /&gt;
    order_id INT,&lt;br /&gt;
    product_id INT,&lt;br /&gt;
    quantity INT,&lt;br /&gt;
    FOREIGN KEY (order_id) REFERENCES orders(id),&lt;br /&gt;
    FOREIGN KEY (product_id) REFERENCES products(id),&lt;br /&gt;
    PRIMARY KEY (order_id, product_id)&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Advantages of the Relational Model ==&lt;br /&gt;
&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Data Integrity&amp;#039;&amp;#039;&amp;#039;: The system ensures that all relationships are valid.&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;No Duplication&amp;#039;&amp;#039;&amp;#039;: Information is stored in one place and linked through keys.&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Flexibility&amp;#039;&amp;#039;&amp;#039;: Easy to add new relationships and modify the structure.&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Efficiency&amp;#039;&amp;#039;&amp;#039;: Fast data search and processing thanks to indexes.&lt;br /&gt;
&lt;br /&gt;
== Practical Example ==&lt;br /&gt;
Let’s consider a simple blog system:&amp;lt;syntaxhighlight lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
-- Users table&lt;br /&gt;
CREATE TABLE users (&lt;br /&gt;
    id INT PRIMARY KEY AUTO_INCREMENT,&lt;br /&gt;
    username VARCHAR(50),&lt;br /&gt;
    email VARCHAR(100),&lt;br /&gt;
    created_at DATETIME&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
-- Posts table&lt;br /&gt;
CREATE TABLE posts (&lt;br /&gt;
    id INT PRIMARY KEY AUTO_INCREMENT,&lt;br /&gt;
    user_id INT,&lt;br /&gt;
    title VARCHAR(200),&lt;br /&gt;
    content TEXT,&lt;br /&gt;
    published_at DATETIME,&lt;br /&gt;
    FOREIGN KEY (user_id) REFERENCES users(id)&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
-- Comments table&lt;br /&gt;
CREATE TABLE comments (&lt;br /&gt;
    id INT PRIMARY KEY AUTO_INCREMENT,&lt;br /&gt;
    post_id INT,&lt;br /&gt;
    user_id INT,&lt;br /&gt;
    comment_text TEXT,&lt;br /&gt;
    created_at DATETIME,&lt;br /&gt;
    FOREIGN KEY (post_id) REFERENCES posts(id),&lt;br /&gt;
    FOREIGN KEY (user_id) REFERENCES users(id)&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;In this example:&lt;br /&gt;
&lt;br /&gt;
* A user can create multiple posts (one-to-many)&lt;br /&gt;
* Each post can have multiple comments (one-to-many)&lt;br /&gt;
* Each comment is linked to both a post and a user&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
Relational databases are a powerful tool for organizing data in an application. Understanding the basic principles of how they work is crucial for beginner developers. A well-designed database structure makes an application more reliable, efficient, and easier to maintain.&lt;br /&gt;
&lt;br /&gt;
[[wj-ru:Реляционные базы данных для начинающих]]&lt;br /&gt;
[[wj-de:Relationale Datenbanken für Anfänger]] &lt;br /&gt;
[[wj-fr:Bases de données relationnelles pour débutants]] &lt;br /&gt;
[[wj-it:Basi di dati relazionali per principianti]]&lt;br /&gt;
[[wj-es:Bases de datos relacionales para principiantes]]&lt;/div&gt;</summary>
		<author><name>Philip</name></author>
	</entry>
</feed>