开发者

Database display: adding a new revolver late in the game?

开发者 https://www.devze.com 2023-03-23 05:47 出处:网络
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

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.

1 equals a, b, and c 2 equals b, c, and d...

So, everything revolves around the numeric data type.

Now, here's where I've got a kog in my mar:

a_1 and a_2 equal 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 t开发者_开发技巧ime. 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.


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:

SELECT GROUP_CONCAT(Name SEPARATOR ';'), Col2, Col3 FROM People GROUP BY Ssn;

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号