建立一个具有替代名称的人员数据库并将所有名称链接在一起

发布于 2024-11-08 21:35:11 字数 437 浏览 0 评论 0原文

我正在为一个小型纪念馆博物馆创建一个数据库。这主要是为皇家活动而设计的,但也有其他领域。因此,大多数作品都与一个人相关,并且应该可以搜索有关特定人的所有作品。

我遇到的问题是,在皇室中,一个人的名字在一生中会改变,有时会改变几次,这是很常见的。应该可以通过任何名称搜索它们,但以任何名称显示所有片段。这些作品仍应列在所写名称下。

因此,我需要某种方式来存储所有名称,同时在相关的地方将它们链接在一起。然后就可以轻松搜索任何名称。

我想到的两种方法是使用一个备用名称表,该表具有返回到“人员”表的外键,那么问题是搜索必须在两个表中进行搜索,并在必要时引用回“人员”。我想不出有什么容易做到的事情。

另一种方法是在一个表中列出所有名称,并使用另一个表使用 2 个外键链接它们。

是否有任何简单的方法可以使用这些方法进行搜索,或者有任何更好的方法来首先创建数据库?

谢谢

I'm creating a database for a small museum of commemorative pieces. This are mostly made for royal events but there are other areas as well. Therefore, most pieces are related to a person and it should be possible to search for all pieces about a particular person.

The problem I'm having is that in royalty, it is quite common that a person's name will change, sometime several times, throughout their life. It should be possible to search for them by any name, but bring up all the pieces under any name. The pieces should still be listed under the name that is written on.

Therefore, I need some way of storing all the name, while linking them together where relevant. Then being able to easily search for any name.

2 ways I have thought of are to have an Alternate Names table that has a foreign key back to the Person table, the problem then is that a search has to search in both tables and reference back to Person if necessary. I can't think of an easy to do that.

The other way would be to list all names in one table, and have another table that links them using 2 foreign keys.

Is there any easy way to search using either of these methods, or any better method for creating the database in the first place?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黑白记忆 2024-11-15 21:35:11

由于 Person 和 Name 之间存在一对多关系,因此我将其结构如下:

  • Piece: PieceID, PersonID, Foo, ...
  • Person: PersonID, Bar, ...
  • Names: NameID, PersonID, Name, 。 ..

您的查询将是:

SELECT Foo, Bar, Name
FROM Names
    JOIN Person USING(PersonID)
    JOIN Piece USING(PersonID)
WHERE Names.Name LIKE '$query'

Since there's a one-to-many relationship between Person and Name, I would structure it as such:

  • Piece: PieceID, PersonID, Foo, ...
  • Person: PersonID, Bar, ...
  • Names: NameID, PersonID, Name, ...

Your query would then just be:

SELECT Foo, Bar, Name
FROM Names
    JOIN Person USING(PersonID)
    JOIN Piece USING(PersonID)
WHERE Names.Name LIKE '$query'
孤独患者 2024-11-15 21:35:11

听起来你走在正确的轨道上。

表:

  • Piece
  • Person
  • Pseudonym
  • PersonPsuedonym

PersonPseudonyms 表当然是 Person 和 Pseudonym 之间的映射表。

您应该能够轻松地将人员连接到别名,方法是将人员连接到人员别名,然后将别名连接到人员别名,然后根据别名过滤您要搜索的名称。

You sound like you are on the right track.

Tables:

  • Piece
  • Person
  • Pseudonym
  • PersonPsuedonym

The PersonPseudonyms table of course being a mapping table between Person and Pseudonym.

You should be able to easily join Person to a Pseudonym by joining Person to PersonPseudonym, then Pseudonym to PersonPseudonym, then filtering on Pseudonym for the name you are searching for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文