The role of foreign keys in SQL database

Category: Ruby :: Published at: 31.05.2023

5 rules, why we use Foreign Keys in our databases:


  1. Relationships establishment - we can create relations between tables, and even inner join relation within one table between two records
  2. Data Integrity - for example, you can create an order with client_id for client which does not exist in the database
  3. Data consistency and accuracy - when foreign key is defined, it restricts the values that can be inserted or updated in the referencing column
  4. Data querying - thanks to the foreign keys we can retrieve data from multiple tables faster and easier
  5. Data maintenance - it helps cascading updates and deletions, preventing locks mechanisms

Run one spec multiple times

Category: Ruby :: Published at: 22.05.2023

Simple code to run one spec multiple times:

for i in `seq 10`; do rspec spec; done

How to use basic Redis commands?

Category: Ruby :: Published at: 30.01.2023

Redis is quite easy to use, it's just basic key->value database which can be used in many different cases.

Let's assume, we already have Redis server setup in our application, and only need to use it.

Read more

Cheatsheet about extending Ruby classes

Category: Ruby :: Published at: 10.06.2022

Here is my small cheatsheet which will help you to extend any Ruby class.

I found out it very helpful and i hope, it will also be a nice help for you.

Read more

About optimistic and pessimistic locking in Rails

Category: Ruby :: Published at: 07.06.2022

Ruby on Rails is very smart framework and it let us to handle with many things in very easy way.

There is no exception when we think about optimistic and pessimistic locking. I will show you how to handle it very fast.

Read more

MonkeyPatching in Ruby - simple example

Category: Ruby :: Published at: 25.05.2023

MonkeyPatching in Ruby is actually extremely easy to understand and use.

We can monkey patch any ruby class, and this is how to do it.

Read more