Advertisement
Guest User

Untitled

a guest
May 27th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. -- cards are what you review. easy!
  2. CREATE TABLE cards (
  3. id integer primary key,
  4. -- the epoch milliseconds of when the card was created
  5. nid integer not null,
  6. -- notes.id
  7. did integer not null,
  8. -- deck id (available in col table)
  9. ord integer not null,
  10. -- ordinal, seems like. for when a model has multiple templates, or thereabouts
  11. mod integer not null,
  12. -- modified time as epoch seconds
  13. usn integer not null,
  14. -- "From the source code it appears Anki increments this number each time you synchronize with AnkiWeb and applies this number to the cards that were synchronized. My database is up to 1230 for the collection and my cards have various numbers up to 1229." -- contributed by Fletcher Moore
  15. type integer not null,
  16. -- in anki1, type was whether the card was suspended, etc. seems to be the same. values are 0 (suspended), 1 (maybe "learning"?), 2 (normal)
  17. queue integer not null,
  18. -- "queue in the cards table refers to if the card is "new" = 0, "learning" = 1 or 3, "review" = 2 (I don't understand how a 3 occurs, but I have 3 notes out of 23,000 with this value.)" -- contributed by Fletcher Moore
  19. due integer not null,
  20. ivl integer not null,
  21. -- interval (used in SRS algorithm)
  22. factor integer not null,
  23. -- factor (used in SRS algorithm)
  24. reps integer not null,
  25. -- number of reviews
  26. lapses integer not null,
  27. -- possibly the number of times the card went from a "was answered correctly" to "was answered incorrectly" state
  28. left integer not null,
  29. -- 0 for all my cards
  30. odue integer not null,
  31. -- 0 for all my cards
  32. odid integer not null,
  33. -- 0 for all my cards
  34. flags integer not null,
  35. -- 0 for all my cards
  36. data text not null
  37. -- currently unused for decks imported from anki1. maybe extra data for plugins?
  38. );
  39.  
  40. -- col is a collection of decks
  41. CREATE TABLE col (
  42. id integer primary key,
  43. -- seems to be an autoincrement
  44. crt integer not null,
  45. -- there's the created timestamp
  46. mod integer not null,
  47. -- last modified in milliseconds
  48. scm integer not null,
  49. -- a timestamp in milliseconds. "schema mod time" - contributed by Fletcher Moore
  50. ver integer not null,
  51. -- version? I have "11"
  52. dty integer not null,
  53. -- 0
  54. usn integer not null,
  55. -- 0
  56. ls integer not null,
  57. -- "last sync time" - contributed by Fletcher Moore
  58. conf text not null,
  59. -- json blob of configuration
  60. models text not null,
  61. -- json object with keys being ids(epoch ms), values being configuration
  62. decks text not null,
  63. -- json object with keys being ids(epoch ms), values being configuration
  64. dconf text not null,
  65. -- json object. deck configuration?
  66. tags text not null
  67. -- a cache of tags used in this collection (probably for autocomplete etc)
  68. );
  69.  
  70. -- dunno what this is yet. my deck has 7. usn is -1, type is 1, and oid varies.
  71. CREATE TABLE graves (
  72. usn integer not null,
  73. oid integer not null,
  74. type integer not null
  75. );
  76.  
  77. -- notes are the new facts, which can be used by different cards.
  78. CREATE TABLE notes (
  79. id integer primary key,
  80. -- epoch seconds of when the note was created
  81. guid text not null,
  82. -- globally unique id, almost certainly used for syncing
  83. mid integer not null,
  84. -- model id
  85. mod integer not null,
  86. -- modified timestamp, epoch seconds
  87. usn integer not null,
  88. -- -1 for all my notes
  89. tags text not null,
  90. -- space-separated string of tags. seems to include space at the beginning and end of the field, almost certainly for LIKE "% tag %" queries
  91. flds text not null,
  92. -- the values of the fields in this note. separated by 0x1f (31).
  93. sfld integer not null,
  94. -- the text of the first field, used for anki2's new (simplistic) uniqueness checking
  95. csum integer not null,
  96. -- dunno. not a unique field, but very few repeats
  97. flags integer not null,
  98. -- 0 for all my notes
  99. data text not null
  100. -- empty string for all my notes
  101. );
  102.  
  103. -- revlog is review history; it has a row for every single review you've ever done!
  104. CREATE TABLE revlog (
  105. id integer primary key,
  106. -- epoch-seconds timestamp of when you did the review
  107. cid integer not null,
  108. -- cards.id
  109. usn integer not null,
  110. -- all my reviews have -1
  111. ease integer not null,
  112. -- which button you pushed to score your recall. 1(wrong), 2(hard), 3(ok), 4(easy)
  113. ivl integer not null,
  114. -- interval
  115. lastIvl integer not null,
  116. -- last interval
  117. factor integer not null,
  118. -- factor
  119. time integer not null,
  120. -- how many milliseconds your review took, up to 60000 (60s)
  121. type integer not null
  122. );
  123.  
  124.  
  125. CREATE INDEX ix_cards_nid on cards (nid);
  126. CREATE INDEX ix_cards_sched on cards (did, queue, due);
  127. CREATE INDEX ix_cards_usn on cards (usn);
  128. CREATE INDEX ix_notes_csum on notes (csum);
  129. CREATE INDEX ix_notes_usn on notes (usn);
  130. CREATE INDEX ix_revlog_cid on revlog (cid);
  131. CREATE INDEX ix_revlog_usn on revlog (usn);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement