简体   繁体   中英

Storing data for a spaced-repetition learning program. Should I use multiple tables in the database

I have an sqlite database for my program which uses flaschards and the SuperMemo2 algorithm. The table at the moment contains the follow fields:

  • id Integer
  • FrontText NVARCHAR ,
  • ReverseText NVARCHAR ,
  • eFactor real ,
  • interval Integer ,
  • count Integer

I am trying to figure out if I should split them in to 2 tables or not. I understand that it is good to split related data into their own tables. However, with a table of just 5 fields and an id column would it still be worth dividing it into 2 separate tables, one for the SuperMemo2 (eFactor, interval and count) and one for the flashcard card (frontText, reverseText)? I feel as if a huge of advantage of using a single table is that it provides simpler queries and a more simple solution, overall.

I haven't used databases much so I'm trying to learn what is considered good practice when creating/designing them.

It sounds like you may be dealing with more info than your table reflects. The three fields that relate to the algorithm are specific to a user and card, but your table does not show a user field.

I would set it up with 2 tables.

Cards (id, frontText, ReverseText)
SuperMemo2 (id, card_id, user_id, eFactor, interval, count)

The Cards table defines the text that appears on the card, and the SuperMemo2 table defines the algorithm parameters for each user-card combination.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM