TP-Structures
Ideas for bitweaver Universal Structures
Created by: William Leibzon, Last modification: 28 Jan 2005 (12:48 UTC)
tiki_blog_posts: post_id, content_id, blog_id, trackback_to,trackbacks_from
Notes: trackbacks_to and trackbacks_from are default "a:():{}" almost always
tiki_nexus_menu: menu_id, plugin_guid, title, description, type, editable
tiki_nexus_menu_items: item_id, menu_id, parent_id, po, title, hint, rsrc, rsrc_type, perm
tiki_categories: category_id, name, description, parent_id, hits
tiki_category_objects: cat_object_id, category_id
tiki_categorized_objects: cat_object_id, object_type, object_id, description, created, name, href, hits
Notes:
object_type is tikipage, blog, etc
description is somewhat similar to hint
name is similar to title
href is "/wiki/index.php?pge_id=7" etc
tiki_structures: structure_id, root_structure_id, content_id, level, pos, page_alias, parent_id
tiki_structure (primary key is structure_id):
structure_id, content_id, user_id, name, description, parent_id, created_on, last_modified_on
This table is used to store minimum identifying information for each specific structure, including user who created it, structure name and description.
Structure_Id - integer used to specify one structure. Equvalent to:
tiki_structures: structure_id, tiki_nexus_menu: menu_id, tiki_blog: blog_id, tiki_categories: category_id
Content_Id - integer used to connect the structure to content_object table, this is used in part to provide permissions for the structure and to make structure available for inclusion as content under different content pages. Equivalent to:
tiki_structures: object_id
User_Id - integer specifying which user created this structure (good for user-specific menus too!). Equivalent to:
tiki_blogs: user_id
Name - short name for this structure. Equivalent to:
tiki_blogs: title, tiki_categories: name, tiki_nexus_menu: title
Description - longer description of the structure. Equivalent to:
tiki_blogs: description, tiki_categories: description, tiki_nexus_menu: description
Parent_Id - describes highier-level this this is one linked to. This can be used with categories although it would be better to replace with linking of multiple items into multi-layer structure, so- consider it reserved for the future for now. Equivalent to:
tiki_categories: parent_id
Created_On - date when the structure was originally created on. Equivalent to:
tiki_blogs: created
Last_Modified_On - data when structure was last modified on. Equivalent to:
tiki_blogs: last_modified
tiki_structure_types (primary key is structure_type_id):
structure_type_id, description, maintainer_url, handler_package, handler_class, handler_file
This table is used as way to specify which objects are able to use bitweaver structures and to provide reference to those objects. This is somewhat similar to how tiki_content_types table is used.
Structure_Type_ID - unique id used when referring to this type of object
Description - descrition of the type of object using the scructure. Example: Blog or Category
Maintainer_URL - URL referring to the organization that maintains this type of structured object. Usually this would be "http://www.bitweaver.org"
Handler_Package - bitweaver package where the class is defined. Examples: Wiki and Blogs
Handler_Class - PHP class responsible for handling this structure type. Examples: TikiBook and TikiBlogPost
Handler_File - The actual php file where the class is defined
tiki_structure_objects (primary key is structure_object_id):
structure_object_id, structure_id, structure_type_id
This table provides information on each specific use structure in different object types
Structure_Object_ID - The unique id corresponding to specific use of specific structure. There should be one-one correspondence from structure_object_id and actual object_id (such as blog_id or nexus_menu_id) that is using the structure, however not all objects that use this structure may have their own object table and since multiple of the same type of objects could be created that use the same strucuture, there is a need for unique structure_object_id. Additionally if structure_object_id was not there and for example nexus_menu was referring directly to structure_id, it would have created a problem when menu is deleted as then you have to specifically check if there are any other menus using the same structure before deleting from tiki_structure_objects table''
Note: Unsure if needed or how to do: tiki_structures: level, tiki_categorized_objects: hits, tiki_nexus_menu_item: perm
tiki_structure_item (primary key is structure_item_id):
structure_item_id, item_type, item_id, url, name, description, created_on, last_modified_on,
This table is used to store information about specific item in the structure, including its name and description and which actual item (content of bitweaver or reference to somewhere else) it refers to.
Structure_item_id - integer used to specify each line/item in the structure. Equivalent to:
tiki_structures: structure_id, tiki_nexus_menu_items: item_id, tiki_blog_posts: post_id, tiki_categorized_objects: cat_object_id
Item_type - Type of item object, describes what type of item_id this is. Can be:
content_id - Item_ID is Content_id
blog_id - Item_ID is Blog_id
structure_id - Item_ID = Structure_ID
URL - Item_Id is not used, instead URL specifies full URL
Equivalent to:
tiki_categorized_objects: object_type, tiki_nexus_menu_items: rsrc_type
Item_id - id of the content for this item, usually same as Content_ID. Equivalent to:
tiki_categorized_objects: object_id, tiki_nexus_menu_items: rsrc, tiki_structures: content_id, tiki_blog_posts: content_id
Note: Possibly get rid of Item_type and replace Item_id in table with Content_ID
URL - when its non-standard or external object, it specifies full URL to redirect to, this is used when item_id is NULL. Equivalent to:
tiki_categorized_objects: href, tiki_nexus_menu_items: rsrc
Name - Short name that will appear when listing this structure instead of original page_name (if not present, original name from structure is to be used). Equivalent to:
tiki_categorized_objects: name, tiki_nexus_menu_items: title, tiki_structure: page_alias
Description - Longer description that maybe used. Equivalent to:
tiki_categorized_objects: description, tiki_nexus_menu_items: hint
Created_On - Date when this structure item was created. Equivalent to:
tiki_categorized_objects: created
Last_Modified_On - Date when this structure item was last modified
tiki_structure_item_position (primary_key is combination of tiki_structure_id, tiki_structure_item_id and pos):
structure_id, structure_item_id, pos, parent_id
This table is used to link structure items to actual structure that they belong to and describes how those items are positioned inside the structure
Structure_id - integer used to specify one structure. Equvalent to:
tiki_structures: root_structure_id, tiki_nexus_menu_items: menu_id, tiki_blog_posts: blog_id, tiki_categorized_objects: category_id
Parent_id - integer specifying top level for multi-level menus & structures; Equivalent to:
tiki_structures: parent_id, tiki_nexus_menu_items: parent_id
Pos - integer which specifies position of the menu relates to ALL other items (no matter what level, within same level highier position is displayed lower and parent_id must have position that is lower then any child). Equivalent to:
tiki_structures: pos, tiki_nexus_menu_items: po
tiki_structure_attrib_names -(primary key is structure_attrib_name_id):
structure_attrib_name_id, attrib_name, structure_type_id
This table specifies additional attributes that can be added for specific structure_items by some structure types that need this. Each type would register its own list of additional attribute names when package for that structure type is installed.
Structure_Attrib_Name_ID - ID for this attribute name
Attrib_name - Name of the attribute, such as "trackback_to" and "trackback_from" for blogs
Structure_Type_ID - ID for type of structure that uses these attribute, see tiki_structure_types tables
tiki_structure_item_attrib (primary key is combination of structure_item_id and structure_attrib_name_id):
structure_item_id, structure_attrib_name_id, attrib_value
This table is used to specify additional structure item attributes
Attrib_value - arbitrary data value
Below is SQL code to retrieve data for list of items in the structure when its id is specified as STRUCTURE-ID. It shows that it still can be done with one database operation just like it was for single item tables (such as nexus_menu_items or tiki_blog_posts):
SELECT tiki_structure_item.structure_item_id, tiki_structure_item.item_type, tiki_structure_item.item_id, tiki_structure_item.url, tiki_structure_item.name, tiki_structure_item.description, tiki_structure_item_position.pos, tiki_structure_item_position.parent_id FROM tiki_structure_item, tiki_structure_item_position WHERE tiki_structure_item_position.stucture_item_id = tiki_structure.structure_item_id AND tiki_structure_item_position.structure_id = STRUCTURE-ID ORDER BY tiki_structure_item_position.pos
tiki_blogs (replaces original, primary key is blog_id):
blog_id, structure_object_id, content_id, public, posts, max_posts, hits, activity, heading, use_find, use_title, add_data, add_poster, allow_comments
Note: blog is a very special structure that is a content object in its own right, especially since comments are allowed with it, so has its own content_id field in the table; note also that blog post is also a separate content type
tiki_nexus_menu (replaces original, primary key is menu_id):
menu_id, structure_object_id, plugin_guid, title, description, menu_type, editable
Note: title and description can be removed from nexus_menus and tiki_structure title and description used intead, however for menus it might be good to be able to override it and there is nothing wrong with just having it be NULL be default
Below is SQL code to retrieve information about specific BLOG based on its BLOG-ID from the database, it shows that it can still be done with one database lookup just like it was before when it was single tiki_blogs table:
SELECT tiki_blogs.blog_id, tiki_structure.name, tiki_structure.description, tiki_structure.user_id, tiki_structure.created-on, tiki_structure.last_modified_on, tiki_blogs.public, tiki_blogs.posts, tiki_blogs.max_posts, tiki_blogs.hits, tiki_blogs.activity, tiki_blogs.heading, tiki_blogs.use_find, tiki_blogs.use_title, tiki_blogs.add_data, tiki_blogs.add_poster, tiki_blogs.allow_comments FROM tiki_blogs, tiki_structure, tiki_structure_objects, tiki_structure_types WHERE tiki_structure_objects.tiki_structure_object.id = tiki_blogs.tiki_structure_object_id AND tiki_structure_objects.tiki_structure_id = tiki_structure.tiki_structure_id AND tiki_structure_objects.tiki_structure_type_id = tiki_structure_types.tiki_structure_type_id AND tiki_structure_types.handler_class='TikiBlog' AND tiki_blog.blog_id = BLOG-ID