Let's use numbers and letters. My numbers are my primary key. They have always been exclusive, so I've let the database revolve around the numbers. The letters represent different data types that fall beneath the numbers which are the primary key. Sometimes there is a_1, a_2, a_n, b_1, b_2, b_n, etc.
我们用数字和字母。我的号码是我的主键。它们一直是排他性的,所以我让数据库围绕着数字旋转。这些字母代表不同的数据类型,这些数据类型落在作为主键的数字下面。有时有a_1, a_2, a_n, b_1, b_2, b_n,等等。
1 equals a, b, and c 2 equals b, c, and d...
1等于a b c 2等于b c d…
So, everything revolves around the numeric data type.
所以,一切都围绕着数字数据类型。
Now, here's where I've got a kog in my mar:
现在,我在我的mar里有一个kog:
a_1 and a_2 equal 1.
a_1和a_2等于1。
It looks like it's no big deal, but there's some communicative issue. They're equal when you read left-to-right, but not when you read right-to-left.
这看起来没什么大不了的,但是有一些交流的问题。当你从左到右读的时候它们是相等的,但是当你从右到左读的时候它们就不一样了。
Even if I explain it in different terms, it seems like it doesn't matter, but there's the issue of exclusivity in my primary key. I saw an example in a book that said this often happens with time. For example, if you have a person's name: "Mary Smith", and then she gets wed and becomes "Mary Charles", then you have to add a new name. If you didn't plan on it, then you need to add a date field. What the book doesn't cover, though, is how I can force the data to always come up showing both names. So, I want to make sure any time someone looks up Mary Smith's name, they get Mary Smith; Mary Charles.
即使我用不同的术语来解释,似乎也不重要,但我的主键中有排他性的问题。我在一本书中看到过这样的例子,书中说这经常发生在时间上。例如,如果你有一个人的名字:“玛丽·史密斯”,然后她结婚,成为“玛丽·查尔斯”,那么你必须加上一个新名字。如果您没有计划,那么您需要添加一个日期字段。不过,这本书没有提到的是,我如何能迫使数据总是显示两个名字。所以,我想确定的是,每当有人查到玛丽·史密斯的名字,他们就会得到玛丽·史密斯;玛丽查尔斯。
1 个解决方案
#1
0
I'm not sure it this will help but you can generate the ; separated list of names in the case where you have multiple entries using GROUP_CONCAT and GROUP_BY. For example:
我不确定这是否有用,但你可以生成;在使用GROUP_CONCAT和GROUP_BY有多个条目的情况下,分离的名称列表。例如:
SELECT GROUP_CONCAT(Name SEPARATOR ';'), Col2, Col3 FROM People GROUP BY Ssn;
通过Ssn从人员组中选择GROUP_CONCAT(名称分隔符';')、Col2、Col3;
#1
0
I'm not sure it this will help but you can generate the ; separated list of names in the case where you have multiple entries using GROUP_CONCAT and GROUP_BY. For example:
我不确定这是否有用,但你可以生成;在使用GROUP_CONCAT和GROUP_BY有多个条目的情况下,分离的名称列表。例如:
SELECT GROUP_CONCAT(Name SEPARATOR ';'), Col2, Col3 FROM People GROUP BY Ssn;
通过Ssn从人员组中选择GROUP_CONCAT(名称分隔符';')、Col2、Col3;