Skip to content

Instantly share code, notes, and snippets.

@janherich
Last active July 24, 2017 16:46
Show Gist options
  • Save janherich/c0cddd44e0e679b3414b3e0ea1a3abd2 to your computer and use it in GitHub Desktop.
Save janherich/c0cddd44e0e679b3414b3e0ea1a3abd2 to your computer and use it in GitHub Desktop.
Database denormalisation
;; Subset of current db structure
{:chat-animations
{"console"
{:parameter-box
{:height 300
:changes-counter 17}}}
:chat-loaded-callbacks
{"console" nil
"wallet" nil
"mailman" nil
"browse" nil
"demo-bot" nil}
:chat-ui-props
{"console"
{:prev-command "password"
:show-suggestions? false}}
:chats
{"console"
{:updated-at "timestamp"
:messages [{:message-status "seen"
:message-id "someid1"}
{:message-status "seen"
:message-id "someid2"}]}}
:message-data
{:short-preview
{"someid1" nil
"someid2" nil}
:preview
{"someid1" nil
"someid2"
{:markup [:text {:style "!important"} "msg2"]}}}}
;; Subset of proposed new db structure
{:message-by-id
{"someid1"
{:message-status "seen"
:message-id "someid1"}
"someid1"
{:message-status "seen"
:message-id "someid2"
:preview
{:markup [:text {:style "!important"} "msg2"]}}}
:chat-by-id
{"console"
{:chat-animations
{:parameter-box
{:height 300
:changes-counter 17}}
:chat-loaded-callbacks
{}
:chat-ui-props
{:prev-command "password"
:show-suggestions? false}
:updated-at "timestamp"
:messages [[:message-by-id "someid1"]
[:message-by-id "someid2"]]}}}
@jeluard
Copy link

jeluard commented Jul 24, 2017

@janherich Looks great! Definitively the right direction. Not so sure about the -by-id suffix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment