aviaryan / Clipjump

:clipboard: Clipboard Manager for Windows, built in AutoHotkey
http://clipjump.sourceforge.net/
381 stars 61 forks source link

Use database for clips/channel management #88

Open aviaryan opened 8 years ago

aviaryan commented 8 years ago

Continuing from #13

Pros of switching to sqlite:

  1. Lesser bugs
  2. No need to continuously rename clip files. (pain for cloud syncing)
  3. Extensible (extra attributes can be added to clips)
  4. Open to users ( http://sqlitebrowser.org )
hoppfrosch commented 8 years ago

As you marked this as ready: Any guess, when we will see this released?

aviaryan commented 8 years ago

I have not implemented it yet, so no due date. ( Ready -> In Progress -> Done in waffle)

aviaryan commented 8 years ago

Thinking about the schema for Clips table, it may go something like the following.

id, PRIMARY KEY AUTO INCREMENT (never changes)
data, text,
channel, int
order number, int
date
clip_file
... other attributes

Similarly we will use a separate table for channels. It should be simple to implement.

I will continue updating this post with more ideas.

hoppfrosch commented 8 years ago

Just a few raw thoughts ... I think you should avoid redundancy with storing clips . Isn't the information about channels stored in the database?

I would suggest something like this

TABLE: channel
-----------------
pk_channel, PRIMARY KEY AUTO INCREMENT (never changes)
name, text
... more attributes

Table: clip
-----------------
pk_clip, PRIMARY KEY AUTO INCREMENT (never changes)
data, text,
clip_file
checksum (md5?)
fk_clipboardformat (foreign key to table clipboardformat)
... other attributes

Table: clip2channel
----------------
pk_clip2channel, PRIMARY KEY AUTO INCREMENT (never changes)
fk_channel (foreign key to table channels)
fk_clip (foreign key to table clip)
date
order number, int

Table: clipboardformat
---------------
pk_clipboardformat, PRIMARY KEY AUTO INCREMENT (never changes)
description, string  (CF_BITMAP, CF_DIB ....)

Remarks:

hoppfrosch commented 8 years ago

Similarly we will use a separate table for columns.

What do you mean here?

aviaryan commented 8 years ago

@hoppfrosch I really like the schema you have suggested. It covers every scope of the application I can think of. For the 4th table, I agree that is not needed as the clipboard-type text is managed by the application (translatable).

Similarly we will use a separate table for columns. What do you mean here?

That was a typo. It's channels, not columns.

hoppfrosch commented 8 years ago

I have had a look onto database schema of Ditto, which uses also sqlite. They provided also a table clipboardformat- so I wasn't sure we need the info for Clipjump as well - else there wasn't anything sophisticated to see ... ;-)

hoppfrosch commented 8 years ago

I had a little time and started with implementation of a SQLite database class for Clipjump, based on the database model suggested above: https://github.com/hoppfrosch/Clipjump/tree/hoppfrosch/feature/class_clipjumpdb

aviaryan commented 8 years ago

@hoppfrosch Great. Looks good. One thing I will like to point out is that a helper method could be used for executing the sql and throwing the message in case an error occurs.

If !base.Exec(SQL)
            throw, { what: " ClipjumpDB SQLite Error", message:  base.ErrorMsg, extra: base.ErrorCode, file: A_LineFile, line: A_LineNumber }
hoppfrosch commented 8 years ago

Which helper method do you mean? Is throwing exception the desired error handling method since you haven't used it throughout the yet existing code?