多对多关系mysql设计 [英] many to many relationship mysql design

查看:91
本文介绍了多对多关系mysql设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很多用户可以有很多标签,所以我设计了这个表

many user can have many tab so I designed this table

user
uId (PK)



user-tab
uId (FK)
tabId (FK)



tab
tabId (PK)

但是当我尝试添加 FK 用户标签出现此错误

but when I try to add FK in user-tab I got this error

1050 - Table '.\db\tab@002duser' already exists 


推荐答案

它不是您的DB设计或现有记录的问题,但是命名问题。

It is not a problem of your DB-Design or existing records, but a naming problem.

命名不带引号的标识符的MySQL规则是instaed CamelCase dash样式写入,请使用

MySQL rules for naming unquoted identifiers are that instaed of CamelCase or dash-style-writing, use

snake_case_writing

snake_case_writing

文件


未加引号的标识符中的字符(不是字符串,值):

Permitted characters in unquoted identifiers (not strings, values):

ASCII:[0-9,az,AZ $ _](基本拉丁字母,数字0-9, ,下划线)

ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)

扩展名:U + 0080 .. U + FFFF

Extended: U+0080 .. U+FFFF

修改

文档中的另一种缩写(此处及更多内容请阅读此处

Another abridgment from the docs (This and more to read here)


命名约定对于由多个单词形成的标识符,
用下划线(而不是大写)分隔每个组件。
因此,使用my_var而不是myVar或MyVar。

Naming Conventions For identifiers formed from multiple words, separate each component with underscore rather than capitalization. Thus, use my_var instead of myVar or MyVar.

避免大写形式,除了类名;类名应以大写字母开始

Avoid capitalization except for class names; class names should begin with a capital letter.

class Item;类Query_arena; class Log_event;避免函数名,
结构元素或以_开头或结尾的变量。

class Item; class Query_arena; class Log_event; Avoid function names, structure elements, or variables that begin or end with '_'.

使用英语中的长函数和变量名。这将使所有开发人员更容易阅读您的
代码。

Use long function and variable names in English. This will make your code easier to read for all developers.

这篇关于多对多关系mysql设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆