Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mechanism for differentiating between "by me" and "liked by me" #7

Closed
simonw opened this issue Sep 2, 2020 · 6 comments
Closed

Mechanism for differentiating between "by me" and "liked by me" #7

simonw opened this issue Sep 2, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Collaborator

simonw commented Sep 2, 2020

Some of the content I'm indexing is by me - photos I've taken, tweets I wrote, commits, comments I posted.

Some of it is stuff that I've "liked" or "bookmarked" in some way - favourited tweets, Pocket articles, starred GitHub repos.

It woud be useful to be able to differentiate between the two.

@simonw simonw added the enhancement New feature or request label Sep 2, 2020
@simonw
Copy link
Collaborator Author

simonw commented Sep 2, 2020

Some opet questions about this:

  • Should I restrict to two exclusive categories here, or should I have a generic category mechanism that can be expanded to more than two?
  • Should an item be able to exist in more than one category? Do I want to be able to mark an indexed item as both by-me and liked-by-me for example? This question is more interesting if the number of categories is greater than two.
  • How should this be modeled? Single column, multiple boolean columns, JSON array, m2m against separate table?
  • What's the best way to make this performant

@simonw
Copy link
Collaborator Author

simonw commented Sep 2, 2020

Relevant: https://charlesleifer.com/blog/a-tour-of-tagging-schemas-many-to-many-bitmaps-and-more/

SQLite supports bitwise operators Binary AND (&) and Binary OR (|) - I could try those. Not sure how they interact with indexes though.

@simonw
Copy link
Collaborator Author

simonw commented Sep 2, 2020

Relevant post: https://sqlite.org/forum/forumpost/9f06fedaa5 - drh says:

Indexes are one-to-one. There is one entry in the index for each row in the table.

You are asking for an index that is many-to-one - multiple index entries for each table row.

A Full-Text Index is basically a many-to-one index. So if all of your array entries really are words, you could probably get this to work using a Full-Text Index.

@simonw
Copy link
Collaborator Author

simonw commented Sep 2, 2020

I'm going to implement the first version of this as an indexed integer category column which has 1 for "about me" and 2 for "liked by me" - and space for other category numerals in the future, albeit a row can only belong to one category.

I'll think about a full tagging system separately.

@simonw
Copy link
Collaborator Author

simonw commented Sep 2, 2020

I'll make category a foreign key to a categories table so Datasette can automatically show the name column.

@simonw
Copy link
Collaborator Author

simonw commented Sep 2, 2020

Default categories:

  • 1 = created
  • 2 = saved

@simonw simonw closed this as completed in 1f64168 Sep 2, 2020
simonw added a commit that referenced this issue Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant