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.
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?
<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.