标记架构:标记表和属性:
表格:
tags (each row only keeps information about a particular tag)
taggings (each row keeps information about trigger and who will receive the trigger )
products_tags (each row keeps information about tag with particular product)
tag_status (each row keeps track of a tag status)
表格:tags 表格的属性:
id(PK)
userId(FK users)(not null)(A tag only belongs to one user, but a user can create multiple tags. So it is one to many relationships.)
genreId(FK products_geners)(not null)
name (string) (not null)
description (string)
status (int) (0=inactive, 1=pending, 2=active, there could be more flag)
rank(int) (rank is the popularity of a particular tag), this field can be use for sorting among similar tags.)
type (int) (0=type1, 1=type2, 2=type3)
photo(string)
visibility (int) (0=public, 2=protected, 3 = private)(private means the tag only visible to assigned users of a product, protected means a tag only visible to all friends and followers of the creator of the tag, public means search by public, such as all admin created tag)
createdAt(timestamp for the tag was created at)
updatedAt (timestamp for the tag last time updated)
deletedAt (default value null) (timestamp when tag was deleted, we need this field because we will delete tag permanently from audit table).
注意:保留第 10 号字段稍后会派上用场。
表格:标签:
此表将用于触发,例如广播其他用户的提要或向他们发送通知。在此表中插入一行后,将有一个读取行的服务执行相关操作以删除该行。
标签表的属性:
Id(PK)
tagId(a tagging row only belongs to a tag, but a tag can have multiple row).
taggableId (id of a user who will receive notification)
taggableType(int) (0=notification, 1=feed message)
taggerId(the person who triggered the broadcast)
taggerType(ad, product, news)
createdAt(timestamp for the tag was created at)
表格:products_tags
从用户的角度来看,用户可以在实例化产品后创建标签,因此下表将保留有关哪些产品具有哪些标签的信息。
taggings table的Attributes的属性:
Id (PK)
productId(FK)
tagId(FK)
表:tag_status
当用户创建标签时,将在此表中创建一个带有 tagId 和默认状态为 inactive/pending 的行,管理员将从标签表中提取所有标签,其中 status=pending/inactive,如果管理员批准了标签,则在查看标签后标记然后标记表中的状态值将被批准,并且标记状态行将被删除。如果 admin 被拒绝,则 tag_status 表的 status 字段的值将被拒绝,并且将广播触发器,并且接收器将向该标签的关联用户发送通知,其中包含他的标签被拒绝的消息。
id(PK)
senderId(Id of the user)
receiverId(Id of admin user)
createdAt(timestamp of created at)
updatedAt(timestamp of updated at)
deletedAt(timestamp of deletedAt) default value null
expiredAt (if a tag never gets approved it will expire after a certain time for removing its information from the database. If a rejected tag gets updated by user then expiredAt will reset to new future time)
status
Message (string varchar(256)) (message for user)