开发者

relating data stored in NoSQL DB to data stored in SQL DB

开发者 https://www.devze.com 2023-01-01 18:54 出处:网络
Whats the best way to use a SQL DB along side a NoSQL DB? I want to keep my users and other data in postgres but have some data that

Whats the best way to use a SQL DB along side a NoSQL DB? I want to keep my users and other data in postgres but have some data that would be better suited for a NoSQL DB like redis.

I see a lot of talk about switching to NoSQL but little talk on integrating it with existing systems. I think it would be foolish to throw the baby out with the bath water and ditch SQL all together, unless it makes things easier to maintain and develop.

I'm wondering what the best approach is for relating data stored in SQL to my data in redis. I was thinking of something along the line of thi开发者_如何学Gos.

  • User object stored in SQL
  • Book object in redis, key sh1 hash of value, value is a JSON string
  • Relations stored in redis, key User.pk:books, value redis set of sha1's

Anyone have experience, tips, better ways?


An article about it: http://www.pythian.com/news/9387/liveblogging-at-confoo-blending-nosql-and-sql/


You can relate things however you want. A popular approach is using non-sequential UUID values as identifiers so that you can query discrete data sources for related data.

The problem is integrity ... without relational constraints, things can get messy. A well coded application can deal with this however.

I would also ensure you use caching wherever popular to avoid the overhead of many datasources.

0

精彩评论

暂无评论...
验证码 换一张
取 消