mercredi 9 mars 2016

Which method is better for storing key value pairs in an sqlite database?

I'm creating a chat bot that will have it's own "memory". It will save the user's input in key-value pairs and later access that memory to see how to construct a response. The database will basically act as a dictionary that grows as the bot recieves input.

The first method would be to simply make two columns and add multiple values to the "Value" column. The value column stores multiple strings. (I'm not sure how I would even do this...) Like so:

 Key     | Values                 |
"i play" | "games","with","music" |
"and i"  | "run", "sleep", "like" |

The other method would be to have one "Key" column that corresponds to multiple values. Each value column stores one single string. Like so:

  Key    | Value 1 | Value 2 | Value 3 |
"i play" | "games" | "with"  |"music"  |
"and i"  | "run"   | "sleep" | "like"  |

I know storing multiple values to one key is a big "no-no" in relational databases, so if there's a better way let me know?

Aucun commentaire:

Enregistrer un commentaire