Welcome Guest, Not a member yet? Register   Sign In
Versioning code in db
#15

[eluser]esra[/eluser]
I'm not sure if this applies in your case. For the content table in my current project, I treat non-null content_id (id), language_id, and revision columns in my content table as a combined primary key. This allows multiple instances of content to exist for each supported language as well as multiple revisions of content for each language instance of content. The content table includes common content columns which remain the same for all content records. Language-specific records for all revisions are stored in a separate table (content_data)using content_data_id and content_id (fk) as primary keys. This approach was used in order to support the MySQL MYISAM engine.

The above might not work with some of the Active Record or ORM solutions mentioned on the wiki or in forum posts. The above approach could be adapted for those by the treating content_id (id), language_id (fk), and revision as a unique key, assuming the INNODB engine is used (referential integrity then applies). Most of the other database engines for CI support referential integrity (via foreign and unique keys), so it should be possible to use the same approach for those database servers. I'm seriously thinking about refactoring my code to use this approach rather that using three columns as a primary key in order to use one of the third-party Active Record solutions.

Within my content table, I use the parent_id field (Adjacency List model) to assign content into generic categories for administration reasons only, allowing the content to be reused as needed by various controllers (blogs, articles, faqs, help, frontpages, products, etc.). Separate nested set tables are used to map content to the hierarchies for the various flavors of content. Those tables usually include id, content_id (fk), lft, and rgt columns and no actual content is stored in those tables (only the hierarchies). This allows any content record to be used by any module and among multiple modules. It also allows new tables to be created for new flavors of content on-the-fly since the column names are identical.


Messages In This Thread
Versioning code in db - by El Forum - 03-18-2008, 08:42 PM
Versioning code in db - by El Forum - 03-19-2008, 01:30 AM
Versioning code in db - by El Forum - 03-19-2008, 01:45 AM
Versioning code in db - by El Forum - 03-19-2008, 03:22 AM
Versioning code in db - by El Forum - 03-19-2008, 04:05 AM
Versioning code in db - by El Forum - 03-19-2008, 04:18 AM
Versioning code in db - by El Forum - 03-19-2008, 04:31 AM
Versioning code in db - by El Forum - 03-19-2008, 06:24 AM
Versioning code in db - by El Forum - 03-19-2008, 06:34 AM
Versioning code in db - by El Forum - 03-19-2008, 06:52 AM
Versioning code in db - by El Forum - 03-19-2008, 07:01 AM
Versioning code in db - by El Forum - 03-19-2008, 07:28 AM
Versioning code in db - by El Forum - 03-19-2008, 07:39 AM
Versioning code in db - by El Forum - 03-19-2008, 07:50 AM
Versioning code in db - by El Forum - 03-19-2008, 07:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB