# TAGS specifications

Main case is 3373 https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3373

FORMAT
=-=-=-
Copied from stack overflow
tags ...

    must be no longer than 35 characters
    spaces are replaced by dashes, no spaces in a tag
    always converts to lower invariant culture
    - (probably not this, utf-8 ok: must use the ascii character set a-z 0-9 + # - .)


SCHEMA
=-=-=-
Two tables:

TAGS
    - name text not null lowercase only
    - id bigserial
    - OwnerId
    - Created
TAGMAP
    - ObjectId
    - ObjectType
    - TagId
    
INDEXES
    - Initial index is on the name of the tag as that will be searched for??
    - After some research I think it's best to just make it, populate it with a great deal of test data and then test query it and see what indexes give the best performance
    


USE-CASES
Add a tag to an object type and id, start typing and a selection list fills in to select from
    - Don't allow the same tag more than once
    - Create a tag if not present (rights?)
Show tags on an object
Find any type or specific type items by a set of tags to include and a set of tags to exclude (i.e. has "red, yellow" but not "green")
Search for text must allow specifying tags to refine
Reporting will require filtering sources of report data by tags

METHODS REQUIRED IN TAG CONTROLLER

- GET tag text by id
- GET tag id by tag text 
- CREATE tag for tagging something
- REMOVE tag (and all tagmap entities)


- GET TAGMAPS LIST (get all object/id entities with this tag)
- CREATE TAGMAP Apply tag to an object / id 
- REMOVE TAGMAP remove tag from object/id
- GET TAGS for object (name id list, main display route)


ROLES / RIGHTS
- Limited roles can tag stuff and remove tags as per their rights to the object type in question but can't make new tags or change existing tags 
- Full roles can make new tags and can edit or delete existing tags
    

RETRIEVAL

Will need to query tags as follows:

ObjectType and Id list of tags (most common)
Objects with one or more tags
Objects that have a set of tags but do not have another set of tags
Objects of a certain type but any id that have a certain tag



