如何在 FileMaker 表中创建新的主键,然后将现有关系修改为基于新创建的键?

发布于 10-26 16:49 字数 461 浏览 6 评论 0原文

我有相当的要求。开发人员创建了我们的数据库,该数据库具有多个布局,并且关系树非常混乱。如果有另一个开发人员进来看看,他说解构我们的系统太耗时、太痛苦,现在考虑创建一个脚本,这样你就可以解决它,直到它被修复。困境如下:我在一个页面上获得了信息,而该页面应该利用选项卡和门户来引用许多不同页面上的信息。然而,所有信息都链接到用户名。该用户名不是静态/序列化的或什么的。因此,如果没有立即发现问题,大量信息可能会链接到此人的“页面”。如果名称不正确,并且有人试图稍微更改用户名,就会破坏这种关系并开始新的关系。这些信息不会消失,但它基本上处于不确定状态,直到您将名称改回原来的名称。我实际上尝试过导出信息,更改不匹配的信息,即将名称从 Jon.Smith 更改为 John.Smith,然后将信息导入到该人的新“页面”,但结果不成功。这让我想到了我的问题,脚本能够解决这个问题吗?同样,对于如何创建这个脚本有什么建议吗?我很抱歉,但我对数据库管理的经验很少,并且不确定为什么这个项目落在我身上。任何帮助将不胜感激。

I have quite the request. A developer created our database that has multiple Layouts with a relationship tree that is very messy. Had another developer come in, take a look at it, he said that it would be too time consuming and painful to deconstruct our system, consider creating a script for now so that you can work around it until it can be fixed. Here's the dilemma: I've got information on one page that is supposed to reference information on a number of different pages utilizing tabs and portals. However, all the information is linked to a username. This username is not static/serialized or what have you. Therefore, if the issue is not caught right away a great deal of information can be linked to this person's 'page'. If the name is incorrect and someone tries to alter the username even slightly, it breaks that relationship and starts a new one. The information does not disappear, but it is basically sitting in limbo somewhere until you change the name back to the original. I've actually tried exporting the information, changing the information that doesn't match, i.e. changing a name from Jon.Smith to John.Smith, and then importing the information to a new 'page' for that person with unsuccessful results. Which brings me to my question, is a script going to be able to fix this problem? Likewise, are there any suggestions to how to create this script? I apologize, but I have very little experience with DataBase management at all, and am not sure why this project fell upon me. Any help would be GREATLY appreciated.

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

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

发布评论

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

评论(2

wchsTech4,你很幸运,因为你的问题很容易解决。您甚至不需要脚本。

首先备份您的文件。然后:

1)创建两个新字段:

  • id(人员表)
    • id 选项:自动输入序列号
  • person_id(与person相关的表)

2)为person表中新的id字段生成序号。

  • 导航至人员布局。
  • '记录'> “显示所有记录”
  • 单击 ID 字段并选择“记录”> “替换字段内容。”
  • 选择“替换为序列号”并接受默认值。请务必选中该框以更新您的下一个序列号。

3) 将刚刚生成的序列号放入相关表中。

  • 导航至相关布局。
  • '记录'> “显示所有记录”
  • 单击 person_id 字段并选择“记录”> “替换字段内容。”
  • 选择“用计算结果替换”旁边的“指定”。
  • 在左上角的下拉列表中,选择相关人员表。
  • 双击 id 字段(您的计算应该是 person::id,其中 person 替换为表的名称)。
  • 单击“确定”,然后单击“替换”。

4)改变关系。

  • 选择“文件”> '管理'> '数据库。'
  • 导航到关系选项卡。
  • 将关系从基于名称更改为基于 ID。

5)测试一切。应该有效。

您的相关记录有可能以这样的方式创建,您还需要修改脚本、网站或此处未提及的其他内容才能继续进行修复工作。调查这一点很重要。

wchsTech4, you are in luck because your problem is easy to fix. You don't even need a script.

BACK UP YOUR FILE(S) FIRST. Then:

1) Create two new fields:

  • id (person table)
    • Options for id: Auto-enter serial number
  • person_id (the table related to person)

2) Generate serial numbers for the new id field in the person table.

  • Navigate to the person layout.
  • 'Records' > 'Show all records'
  • Click in the id field and select 'Records' > 'Replace field contents.'
  • Choose 'Replace with serial numbers' and accept the defaults. Be sure to check the box to update your next serial number.

3) Place the serial numbers you just generated in the related table.

  • Navigate to the related layout.
  • 'Records' > 'Show all records'
  • Click in the person_id field and select 'Records' > 'Replace field contents.'
  • Choose 'Specify' next to 'Replace with calculated results.'
  • In the drop down on the top left, select the related person table.
  • Double click the id field (your calculation should be person::id, with person replaced with the name of your table).
  • Click 'OK' and then 'Replace.'

4) Change the relationship.

  • Select 'File' > 'Manage' > 'Database.'
  • Navigate to the relationship tab.
  • Change the relationship from being based on name to id.

5) Test everything. Should work.

There is a chance that your related records are being created in such a manner that you also need to modify a script, website, or something else not mentioned here to have your fix work going forward. That is important to investigate.

遗失的美好2024-11-02 16:49:37

好吧,作为一般性答案,用户在 FileMaker 中可以执行的任何操作(我所说的用户是指非开发人员,因此定义数据库结构、编写脚本等活动不包括在内)都可以编写脚本。因此,如果您能够通过重置字段的值来“解决”问题,那么,是的,脚本可以做到这一点。

关于您的具体问题,脚本可能不需要导出记录,但可以重置 FileMaker 中字段的值。这可以通过循环遍历需要更改的记录或使用替换字段内容脚本步骤来完成。因此,脚本可以执行以下操作:

Go to Layout[MyLayout] // Go to a layout that is attached to the table you need to search.
Perform Find[Restore] // Restore a find that will show the records you need to change.
Replace Field Contents[Table::Field; "New Value"]

提供比这更多的建议需要实际查看数据库并更多地了解您的特定需求。

Well, as a general answer, just about anything that a user can do in FileMaker (and by user, I mean non-developer, so activities such as defining the database structure, writing scripts, etc., are excluded) can be scripted. So if you're able to "solve" the problem by resetting a field's value, for example, then, yes, a script can do that.

Regarding your specific trouble, a script probably doesn't need to export the records, but could reset the values for the field within FileMaker. This could be done either by looping through the records that need to be changed or by using the Replace Field Contents script step. So a script could do something like this:

Go to Layout[MyLayout] // Go to a layout that is attached to the table you need to search.
Perform Find[Restore] // Restore a find that will show the records you need to change.
Replace Field Contents[Table::Field; "New Value"]

Offering more advice than this would require actually seeing the database and understanding more about your specific needs.

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