简体   繁体   English

foo.foo:提供一个与表本身名称相同的表列是一个坏主意吗?

[英]foo.foo: Is giving a table column the same name as the table itself a bad idea?

I have a very simple table called genre , which looks like this: 我有一个叫做genre的非常简单的表,看起来像这样:

GENRE
=====
id int
genre_category varchar()

genre_category has values like "narrative", "myth", and so on. genre_category具有“叙事”,“神话”等价值观。

genre_category seems like a silly name for the column. genre_category看起来像列的愚蠢名称。 The column could be called genre_type or genre_label or genre_category . 该列可以称为genre_typegenre_labelgenre_category But it seems redundant. 但这似乎是多余的。

So, is there any reason not to just go ahead and call it genre.genre ? 那么,有没有理由不继续称它为genre.genre

EDIT: 编辑:

The bottom line is that it's better to use .name . 最重要的是,最好使用.name Thanks everyone! 感谢大家!

It sounds like you're modeling a genre entity. 这听起来像是在为一个类型实体建模。 Examples horror, drama, romance. 例如恐怖,戏剧,浪漫。 Is this correct? 它是否正确?

Would you be comfortable in calling your genre 's column [name] ? 你是否愿意调用你的genre专栏[name]

此列应称为“名称”,因为这是类型名称。

Why not name the column "category"? 为什么不将列命名为“类别”? Giving your "genre" table a "genre" column seems to say that your genre has a genre, which makes no sense. 给你的“流派”表一个“流派”专栏似乎说你的流派有一种类型,这没有任何意义。 Rather, a genre has a name or type or category or whatever, so you should name it accordingly. 相反,类型有名称或类型或类别或其他类型,因此您应该相应地命名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM