17

I have some questions for REDIS DB:

  • How to ensure data integrity?
  • Are there methods ensure the integrity?
  • Does Redis primary key? or alternatives
  • Foreign key?
  • Referential Integrity?
  • How are the ACID properties to be implemented?

Ever Thanks for a possible feedback

best regards - SB -

viv1d
  • 339
  • 4
  • 5
  • 12

2 Answers2

24

Redis is a key/value store on steroids, not a relational database.

How to ensure data integrity? Are there methods ensure the integrity?

Redis supports different persistence options from the "non safe but very efficient" up to the "safe but not very efficient". See more information at:

Redis also supports a master-slave replication mechanism to protect the data in case of complete node failure.

A single Redis instance always provides data consistency (in the sense of the CAP theorem, not in the sense of ACID).

Does Redis primary key? or alternatives

Redis is a key/value store. All items have a key. There is no concept of primary or secondary key.

Foreign key? Referential Integrity?

These are relational concepts. Redis is not a relational database. Foreign key means nothing (there is no table concept with Redis). Referential integrity is not maintained by Redis, and must be enforced by the client application.

How are the ACID properties to be implemented?

They are not supposed to be implemented since Redis is not a transactional database. There is no rollback mechanism with Redis. However, in term of ACID properties:

  • Atomicity and consistency can be guaranteed for a group of commands with a server-side Lua script
  • Isolation is always guaranteed at command level, and can also be guaranteed for a group of command using a MULTI/EXEC block or a Lua script
  • Durability can be guaranteed when AOF is activated (with systematic fsync)
Didier Spezia
  • 70,911
  • 12
  • 189
  • 154
  • 2
    `Durability can be guaranteed when AOF is activated (with systematic fsync)` <-- is your source for that the antirez link (great link thanks for that btw) Do you know what sort of effect on performance this has? ie does it bring redis back into the same league as SQL/Mongo? – wal Jan 09 '15 at 06:00
  • 2
    The effect on performance is catastrophic. Any RDBMS or NoSQL engine with a write ahead log will perform much better than Redis in this configuration. This is because Redis is single-threaded. In this configuration, fsync are done directly in the event loop. So any fsync systematically block ALL the connections. – Didier Spezia Jan 09 '15 at 16:49
  • 2
    `This is because Redis is single-threaded. In this configuration, fsync are done directly in the event loop` are you sure about this? The Redis Persistence link says "AOF also needs to fork() but you can tune how often you want to rewrite your logs without any trade-off on durability." – timetofly Feb 23 '15 at 01:32
  • 2
    You are confusing the background thread to rewrite the AOF file (to compact it) and the foreground thread with has to perform the sync operations. The only way to guarantee durability is to sync in the event loop, make it slow. – Didier Spezia Feb 23 '15 at 06:39
-1

Redis Graph is the module you need to have better data integrity and relations

Vts
  • 41
  • 7