在 OpenOffice.org 的 Base 中的表单中实现简单的多对多关系

发布于 2024-08-17 06:45:19 字数 589 浏览 8 评论 0原文

我正在做一个小型关系数据库,供一个人在一台计算机上使用。我选择了 OpenOffice.org 的 Base(版本 3.1.1),因为它是免费的,并且对于这种情况来说应该足够了。我的问题的简化版本是:

我有一个文章表,其中包含以下列:ID、标题、内容等......
我有一个关键字表,其中包含以下列:ID、关键字。
我有一个关系表,其中包含以下列:ID、ArticleID、KeywordID

只是多对多关系的基本、经典示例。

然后,我使用 Base 中的“设计视图”创建了一个表单(为使用数据库的用户)并链接到“文章”表,该表单工作正常,并允许我在“文章”表中查看、编辑和创建行。

我的问题是如何以相同的形式包含与关键字的关系。也就是说,我希望用户能够查看并选择哪些关键字属于当前正在表单中查看的文章。

如果重要的话,关键字的数量是有限的(可能是 5-15 个)。首选设置是前面提到的表单中的关键字列表(当然动态链接到关键字表),我已经在每个关键字前面创建了一个复选框,

我已经尝试用 Google 搜索所有可能的关键字,并且我没有提出任何适用于我的情况。我相信答案是使用 SubForms,或者可能是一些我不熟悉的 SQL 语法。任何帮助表示赞赏。

I'm doing a small relational database, to be used by one person on a single computer. I chose OpenOffice.org's Base (version 3.1.1) because it's free and should be more than enough for this case. The simplified version of my problem is:

I have an Articles table, with columns: ID, Title, Content, etc....
I have a Keywords table with columns: ID, Keyword.
I have a Relations table with columns: ID, ArticleID, KeywordID

Just a basic, classic, example of a many-to-many relation.

Then I created a form (for the user using the database) using the 'Design view' in Base and linked to the Articles table, which works fine, and allows me to view, edit and created rows in the Articles table.

My problem is how to include the relation to Keywords in that same form. That is, I want the user to be able to view and choose which keyword(s) belongs to the article currently being viewed in the form.

The number of keywords is finite (probably 5-15) if that matters. A preferred setup would be a list of keywords (dynamically linked to the Keywords table of course) in the previously mentioned form I've already created with a check box in front of each keywords

I've tried Google'ing all possible keywords and I've come up with nothing applicable to my case. I belive the answer is somehow using SubForms, or maybe some SQL syntax I'm not familiar with. Any help appreciated.

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

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

发布评论

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

评论(2

浪菊怪哟 2024-08-24 06:45:19

要更详细地回答这个问题,因为它很早就出现在 Google 搜索中,请参阅以下从头开始创建 movie.odb 文件的视频:

http://www.youtube.com/watch?v=GYawYO8u3_s

关于创建此内容的一些进一步说明:

设置表

  • 原则表必须有一个整数主键设置为 AutoValue
  • 链接表必须具有多列主键,并且两列都必须是整数 必须
  • 在“关系...”对话框中设置表
  • 如果更新选项未从“无操作”更改,则关系消失

关系 子表单

  • 子表单数据>>必须设置映射表的内容
  • 子表单Data>>链接主字段和链接从字段必须设置为相关字段(根据上面讨论的关系...对话框)
  • 应该绘制一个表格控件(焦点必须在当时的子窗体上,以便表格控件位于下面表单导航器中的子表单
  • 应将列插入到表控件中
  • 列数据 >> 数据字段应设置为相关数据的 ID(即不是主表单的 ID)
  • 列数据>>列表内容的类型应设置为“sql”
  • 列 Date >> 列表内容应设置为“SELECT “Genre Name”, “GenreID” FROM “Genre””(其中 Genre Name 是相关字段中的相关字段)表,GenreID 是该表的主键,Genre 是相关表)

To answer this in a little more detail, as it comes up early on Google search, please refer to the following video of creating the movies.odb file from scratch:

http://www.youtube.com/watch?v=GYawYO8u3_s

Some further notes on creating this:

Setting up the tables

  • The principle tables must have an integer primary key that is set to AutoValue
  • The linking table must have a multi-column primary key, and both columns must be integers
  • The table relationships must be set in the Relationships... dialog
  • The relationships disappear if Update options not changed from No action

Setting up the subform

  • The subform Data >> Content must be set to the mapping table
  • The subform Data >> Link master fields and Link slave fields must be set to the related fields (as per the Relationships... dialog discussed above)
  • A table control should be draw (focus must be on the subform at the time, such that the table control sits below the subform in the Form Navigator
  • A column should be inserted into the table control
  • The column Data >> Data field should be set to the ID of the related data (i.e. not that of the main form)
  • The column Data >> Type of list contents should be set to “sql”
  • The column Date >> List content should be set to “SELECT “Genre Name”, “GenreID” FROM “Genre”” (where Genre Name is the relevant field from the related table, the GenreID is the primary key of that table, and Genre is the related table)
别低头,皇冠会掉 2024-08-24 06:45:19

我做了更多搜索,终于找到了解决方案

解释这个问题(以及其他问题)的线程,使用中间表为 Base 中包含多对多关系的数据库创建表单,可以在以下位置找到:

http://user.services.openoffice.org/en/forum/viewtopic.php?p=16159#p16159< /a>

由上述线程的发布者之一 (DrewJensen) 提供的具有功能形式的示例数据库可以在上述发布线程的第 2 页找到并下载。 (名为 movie_2.odb)

使用原始帖子中的示例表和列对解决方案进行简要说明:
诀窍在于创建一个链接到我创建的表单内的关系表的子表单。该子表单应包含一个表控件。然后应在该表控件中创建一列。该列应分配给 KeywordID 列。该列的“列表内容”字段应包含:从“关系”中选择“关键字”、“ID”。
(如果我的说明含糊不清,请查看上面的链接)

I did some more searching and finally found a solution.

A thread explaining this very issues (among other issues), creating form for a database containing many-to-many relation in Base using a middle table, can be found at:

http://user.services.openoffice.org/en/forum/viewtopic.php?p=16159#p16159

A sample database with a functional form by one of the above thread's posters (DrewJensen) can be found and downloaded at page 2 of the above posted thread. (named movies_2.odb)

A brief description of the solution using my example tables and columns from orginial post:
The trick lies in creating a sub-form linked to the Relations table within the form I had created. That sub-form should contain a Table Control. Then a column should be created in that Table Control. The column should be asigned to the KeywordID column. The "List content" field for that column should then contain: SELECT "Keyword", "ID" FROM "Relations".
(just check out the above link if my instructions are cryptic)

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