DB Mappings

20171203 version

Cofacts uses elasticsearch to store all its data, event the relational ones. Elasticsearch "schema", or the index mappings, are defined in rumors-db.

This document contains a visualization of the schema and the reason behind such design.

Mapping







mappings



replyrequests

๐ซ๐ž๐ฉ๐ฅ๐ฒ๐ซ๐ž๐ช๐ฎ๐ž๐ฌ๐ญ๐ฌ

userId
 appId

createdAt
 updatedAt



articlereplyfeedbacks

๐š๐ซ๐ญ๐ข๐œ๐ฅ๐ž๐ซ๐ž๐ฉ๐ฅ๐ฒ๐Ÿ๐ž๐ž๐๐›๐š๐œ๐ค๐ฌ

userId
 appId

score

createdAt
 updatedAt



replies

๐ซ๐ž๐ฉ๐ฅ๐ข๐ž๐ฌ

userId
 appId

type

text

hyperlinks 
(nested)

url

title

summary

reference

createdAt



urls

๐ฎ๐ซ๐ฅ๐ฌ

url
 canonical

title

summary

html
 topImageUrl

fetchedAt



replies:url--urls:url

1
n



replies:title--urls:title




replies:summary--urls:summary




articles

๐š๐ซ๐ญ๐ข๐œ๐ฅ๐ž๐ฌ

replyRequestCount
 lastRequestedAt

createdAt
 updatedAt

text

userId
 appId

references
 (nested)

type
 permalink
 createdAt

userId
 appId

articleReplies 
(nested)

replyId

positiveFeedbackCount
 negativeFeedbackCount

replyType

userId
 appId

status

createdAt
 updatedAt

hyperlinks 
(nested)

url

title

summary

tags



articles:id--replyrequests:id

n
1



articles:requests--replyrequests:timestamps




articles:id--articlereplyfeedbacks:id

n
1



articles:reply--articlereplyfeedbacks:id

n
1



articles:feedbackcounts--articlereplyfeedbacks:score




articles:reply--replies:id

1
n



articles:replytype--replies:type




tags

๐ญ๐š๐ ๐ฌ

title

description

userId
 appId



articles:tags--tags:title

m
n



articles:url--urls:url

1
n



articles:title--urls:title




articles:summary--urls:summary




Requirements

The DB structure above is to fulfill the requirements mentioned in https://github.com/cofacts/rumors-api/issues/35 , including:

Filters

  • Get articles I have replied
  • Get articles with all replies having only negative feedbacks
  • Get articles that has replies marked with "Contains truth" / "Contains misinformation" / "Not artile"
  • Article tag (TBD in cofacts/api#32)

Sortings

  • Using the last reported time

Future directions

not supported yet, but should be available by adding fields or cached fields

Design choice