I have a static table entry that's shared by several databases/website. By static, I mean the data is read but never updated by the websites. Currently, all websites are served from the same server but that may change.

我有一个静态表条目,由几个数据库/网站共享。静态,我的意思是数据被读取但从未被网站更新。目前,所有网站都是从同一台服务器提供的,但可能会发生变化。

I want to minimize the need for creating/maintaining this table for each of the websites, so I thought about turning it to a variable that's stored in a shared library that all websites have access to.

我想尽量减少为每个网站创建/维护此表的需要,因此我考虑将其转换为存储在所有网站都可以访问的共享库中的变量。

The problem is I use an ORM and use foreign key constraints to ensure referential integrity of the ids used from that static table, so by removing that table out of the MySQL database into a variable, how can I still get referential integrity for the ids referenced from that table? Do I have to do it entirely programmatically or is there a trick to still treat the data as if coming from a real db table.

问题是我使用ORM并使用外键约束来确保从该静态表中使用的id的引用完整性,因此通过将该表从MySQL数据库中删除到变量中,我如何仍然获得引用的ID的引用完整性从那张桌子?我是否必须完全以编程方式执行此操作,或者还有一个技巧仍然可以将数据视为来自真正的数据库表。

My database definition (using Propel) originally looked like this, where the refer table had a field linkto that was referencing the id of the entry table. Now that the entry table is in code, I can't do the foreign-key trick any more, or can I somehow get the same effect?

我的数据库定义(使用Propel)最初看起来像这样,其中引用表具有引用条目表的id的字段链接。现在条目表在代码中,我不能再做外键技巧,或者我可以以某种方式获得相同的效果?

  <table name="entry">
    <column name="id" type="INTEGER" primaryKey="true" autoIncrement="true" />
    <column name="title" type="VARCHAR" size="500" required="true" />
  </table>

  <table name="refer">
    <column name="id" type="INTEGER" primaryKey="true" autoIncrement="true" />
    <column name="linkto" type="INTEGER"/>
     <foreign-key foreignTable="entry">
        <reference local="linkto" foreign="id" />
    </foreign-key>
  </table>

And of course are these any other efficient ways to do the same thing? I just don't want to have to repeat that table for several websites.

当然,还有其他任何有效的方法来做同样的事情吗?我只是不想为几个网站重复该表。

1 个解决方案

#1


1

You could create a constraint -- a mighty verbose one, probably, if your id FK is being replaced by a link -- but then you'd still be in the position of maintaining this constraint for each web site. It would help to know what these tables are actually tracking/being used for if you want suggestions for other ways of handling it.

你可以创建一个约束 - 一个强大的冗长,如果你的id FK被一个链接替换了 - 但是你仍然可以为每个网站维护这个约束。如果您想要其他处理方法的建议,将有助于了解这些表实际跟踪/正在使用的内容。

更多相关文章

  1. SQL - 如果存在表条目
  2. 保存在Java桌面应用程序应用程序和网站上使用的个人用户设置的最
  3. 在时间戳和相应的值中选择每天的最后一个条目。
  4. 在社交新闻网站上处理上/下投票
  5. iPhone的网站主题 - 什么是基本成分?
  6. Python爬虫系列(三)多线程爬取斗图网站(皮皮虾,我们上车)
  7. 网站性能优化:Cache为王篇
  8. PHP的网站安全问题? (也可能适用于ASP / Rails /等..)
  9. 使用node.js托管一个asp.net或jsp网站。

随机推荐

  1. 开发具备语音识别功能的 Android* 应用
  2. Android介绍
  3. Android XML解析学习——Sax方式(续)
  4. Android(安卓)studio断点调试(全在这里)
  5. Android Animation学习笔记
  6. Android在Eclipse环境下安装配置
  7. 了解Android
  8. Android webkit image的加载过程解析(二)
  9. Android官方技术文档翻译——Gradle 插件
  10. 获取Android的Java源代码并在Eclipse中关