考虑我有可能与零个或多个标签进行关联的说明表,我会怎么决定做将标签与实体关联,存储标签一次或不存在?
create table notes (
id int , -- primary key
-- other fields
);
create table tagmapping (
noteid int, -- refers notes.id
tagid int, -- refers tags.id
);
create table tags (
int id, -- primary key
tagname varchar(255)
);
VS多次存储相同的标签可能在
create table notes (
int id, -- primary key
-- other fields
);
create table bar (
id id, -- primary key
tag varchar(255),
-- other fields
noteid int -- refers to notes.id, (not unique)
);
什么混乱/优势,我会让自己进入最后的做法?