Skip to content

Instantly share code, notes, and snippets.

@avidrucker
Created June 4, 2024 23:38
Show Gist options
  • Save avidrucker/ecd462be5f13d4916301b119ea4c6187 to your computer and use it in GitHub Desktop.
Save avidrucker/ecd462be5f13d4916301b119ea4c6187 to your computer and use it in GitHub Desktop.
flashcards as they are used by Anki Spaced Repetition Software in 2024
erDiagram
    ERD_NOTES {
        _ notes "A user's data begins with making notes, which are themselves entries of data"
        _ note_types "Different note types can be made too. These determine what fields a note will have"
        _ cards "From a single note, multiple digital cards can be made."
        _ tags "Tags can be put on individual notes."
        _ notes_and_cards "For each note type, there is 1 associated card model"
        _ card_models "Card models store the CSS for a given note type."
        _ card_types "Each card model has 1 or more card types."
        _ field_names "Each note type prescribes a number of fields, their names, their ordering, and which is the primary field."
        _ field_values "Each note will have values for 1 or more fields."
    }

    USER {
        int id PK
        string username UK
        string email UK
        string password
    }
    
    NOTE  {
        _ note "entry collection of data about a word, concept, or thing"
        int id PK 
        array field_values FK
        array tags FK
        int user_id FK "user who made this note"
        int note_type_id FK
    }

    NOTE_TYPE {
        int id PK 
        string name UK
        int primary_field_name_id FK "constraint: unique field value for this note type"
        int card_model_id FK
        int user_id FK "user who made this note type"
    }

    TAG {
        int id PK
        string name UK
    }

    FIELD_NAME {
        int id PK 
        string name "* Enforced as UK for each associated note type"
        boolean primary UK "Unique constraint per note type on associated string value"
        int display_index
        int note_type_id FK
    }

    FIELD_VALUE {
        int id PK
        string value "* May be enforced as UK and/or NOT NULL as designed by note type"
        int field_name_id FK
        int note_id FK
    }

    CARD {
        int id PK 
        int note_id FK
        int card_type_id FK
    }

    CARD_REVIEW_DATA {
        int id PK
        int card_id FK
        int user_id FK
        int reviewed "times the card was reviewed"
        int lapsed "times the card was failed"
        int interval "days till next review"
        date due_on "date of next review"
    }

    CARD_MODEL {
        int id PK
        string name UK 
        string css
        array card_types FK
    }

    CARD_TYPE {
        int id PK
        string name UK
        string front_html
        string back_html
        int index_order
        int card_model_id FK 
    }

    ERD_EXAMPLES {
        _ notes "eg. Notes: 'konnichiwa', 'glutius maximus', 'next word start'"
        _ note_types "eg. Types: JapaneseNote, AnatomyNote, VimNote"
        _ cards "These are the 'actual' digital cards reviewed by the user."
        _ card_review_data "John studied 'konnichiwa' 4 times, and it will be due next on Tuesday."
        _ card_model "JapaneseNote cards are styled with ink and paper styling."
        _ card_type "JapaneseNote cards come in 'reading', 'writing', and 'listening'."
        _ fields "eg. Fields: 'explanation', 'key-binding', 'translation'"
        _ tags "eg. Tags: 'greeting', 'muscle', 'movement'"
    }
    
    NOTE ||--|{ FIELD_VALUE : "has 1 or more"
    NOTE ||--|| NOTE_TYPE : "has 1 and only 1"
    USER ||--o{ NOTE : "can make and have 0 to many"
    USER ||--o{ NOTE_TYPE : "can make 0 to many"
    FIELD_VALUE ||--|| FIELD_NAME : "associates with 1 and only 1"
    NOTE_TYPE ||--|| FIELD_NAME : "can have only 1 primary"
    NOTE_TYPE ||--|| CARD_MODEL : "associates with 1 and only 1"
    CARD_MODEL ||--|{ CARD_TYPE : "can have 1 or more"
    CARD ||--|| CARD_TYPE : "has 1 and only 1"
    NOTE ||--o{ TAG : "have 0 to many"
    CARD ||--o{ CARD_REVIEW_DATA : "can be reviewed 0 or more times"
    USER ||--o{ CARD_REVIEW_DATA : "can generate 0 or more"

    
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment