Introduction to Relational Databases

Just a guy who loves to write code and watch anime.
Search for a command to run...

Just a guy who loves to write code and watch anime.
Sự đa dạng trong các trò chơi tại Sunwin Bên cạnh các trò chơi truyền thống, Sunwin cũng mang đến cho người chơi những trò chơi hiện đại với lối chơi mới mẻ và độc đáo. Các trò chơi này được đầu tư kỹ lưỡng về mặt hình ảnh, âm thanh và hiệu ứng, tạo nên những trải nghiệm giải trí đẳng cấp quốc tế. Chi tiết: https://gideondefoe.com/ve-taisunwin-id/
Qualities that make outstanding builders.

Bipedal vs quadrupedal: how many legs This is about the number of legs the creature walks on. Bipedal. Two legs. Humans, ostriches, T-rex, kangaroos, most fantasy humanoids. Quadrupedal. Four legs. Do

Intro You hear "lerp" and "smoothstep" everywhere in game dev. They sound like math jargon. They're not. Both are small tools that do the same job: smoothly move from one value to another. The problem

What is Kinematics Kinematics is the math field. It's the study of how things move without worrying about forces (which would be dynamics). FK and IK are the two branches: forward kinematics and inver

Intro Textures are usually the biggest cost in a 3D scene. Memory, bandwidth, and load time all get eaten by them. Resizing them is the obvious lever. There's more. This post is about the less obvious

At its core, a relational database organizes data into tables, which consist of rows and columns. Each row represents a record, a single data item, and each column represents a field, a specific type of data within a record.
+----+-------+-----+
| id | name | age |
+----+-------+-----+
| 1 | John | 25 |
| 2 | Alice | 30 |
| 3 | Bob | 35 |
+----+-------+-----+
In this table, each row is a record of an individual’s id, name, and age. Each column specifies what data the field holds.
A schema is a blueprint of how a database is structured. It defines the tables, the fields in each table, and the type of data each field can hold. For the table in the previous section, the schema would specify that id and age are integers and name is a string.
Schemas make sure the data stays consistent by applying rules. These rules include making sure every record has data for each field and that the data matches the specified type.
Relational databases allow tables to be linked, creating relationships between different data items.
These relationships can be:
One-to-One: Each row in Table A is linked to one row in Table B, and vice versa. For example, a person’s passport number is unique to them.
One-to-Many: A single row in Table A can be linked to many rows in Table B. For example, a customer can have multiple orders.
Many-to-Many: Rows in Table A can be linked to multiple rows in Table B, and vice versa. For example, a student can take multiple classes, and a class can have multiple students.
Structured Query Language (SQL) is the standard language for interacting with relational databases. It allows you to perform various operations, such as creating tables, inserting data, querying data, updating data, and deleting data.
SQL is declarative, meaning you describe what you want to do, and the database figures out the most efficient way to do it.
Relational databases are built to be reliable, making sure data stays accurate and consistent through transactions. Transactions in a database follow the ACID properties:
Atomicity: Ensures a transaction is all-or-nothing.
Consistency: Guarantees that a transaction takes the database from one valid state to another.
Isolation: Keeps transactions separate from each other until they’re completed.
Durability: Ensures that once a transaction is committed, it remains so, even in the event of a system failure.
As databases get bigger, searching through them can slow down. Indexes are like special lookup tables that help the database find data faster. Adding an index to a database column is like putting in a bookmark, making it easier to find specific information.
CREATE INDEX name_index ON employees (name);
This index would make queries searching for employees by name much faster.
Transactions in SQL ensure that operations involving multiple steps are either complete fully or not at all.
Here’s a simple example:
BEGIN TRANSACTION;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;
This transaction moves money between accounts, ensuring both operations complete successfully before committing the changes.
Strong Consistency: Changes made by a transaction are immediately visible to all other transactions. This applies to Relational Databases' transactions.
Eventual Consistency: Changes may not be instantly visible but will become so over time, ensuring data consistency across the database eventually. Outside of relational databases, this may apply to other data storage systems.