This document contains information about the new tables added to support
multiple item types:

	s_item_type
	s_attribute_type
	s_attribute_type_lookup
	s_item_attribute_type
	item_attribute
	

The s_item_type table 
=====================

CREATE TABLE s_item_type (
  s_item_type		varchar(10) NOT NULL,
  description		varchar(60) NOT NULL,
  image				varchar(255),
  default_site_type	varchar(10),
  order_no			tinyint(2),
  PRIMARY KEY ( s_item_type )
) TYPE=MyISAM COMMENT='System Item Type';


This table is the top level table defining a particular media type, such
as DVD, VHS or CD.  This table includes a title_prompt so that the title
field can be named differently depending on the item_type at hand.

The new image field is for specify an image to be related to the item_type.  This
is for item_input.php, item_details.php, item_add.php, item_review.php, listings.php, stats.php,etc.

The default_site_type is for when items are manually entered without the use of a 
site-plugin.  When the item_display.php page runs, this default_site_type will used as
a last resort to display site-plugin specific links, etc.  It is up to each plugin to handle
the case where it is being asked to deal with an item it did not actually provide data for.

The s_attribute_type table
==========================

CREATE TABLE s_attribute_type (
  s_attribute_type	varchar(10) NOT NULL,
  description		varchar(60) NOT NULL,
  prompt			varchar(30) default NULL,
  input_type		varchar(255),
  display_type		varchar(255),
  s_field_type		varchar(10),
  site_type			varchar(10),
  PRIMARY KEY ( s_attribute_type )
) TYPE=MyISAM COMMENT='System Attribute table';

This table defines the basic features of an item attribute.  Such things
as the default field prompt, which can be overwritten at s_item_attribute_type
level.

The input_type/display_type fields are interesting, because they support the use
of specific formatting information that is only of use to the PHP process when 
building an input or display field.

Please refer to the typefunctions.txt file for more information on the formatting
functions available for the input_type and display_type fields.

s_field_type
------------
This column is used to define any special columns, that may not actually have a
item_attribute record, or that are used for special purpose when displaying the
item in item_display.php.

Currently we have:

	IMAGE 		- The Cover image attribute.
	CATEGORY	- The attribute type of the Item Category.  The value is stored in item table.
	ITEM_ID		- The item.id display-only attribute type.
	DURATION	- The Borrow Duration attribute type placeholder.  The value is stored in
				item_instance table.
	TITLE		- The Item Title
	STATUSTYPE	- The Item Instance Active Indicator

NOTE: The s_field_type='CATEGORY' s_attribute_type should not allow input of more than
50 characters.  The category will be substr($category,0,50) before insert/update to
ensure this.


The s_attribute_type_lookup table
=================================

CREATE TABLE s_attribute_type_lookup (
  s_attribute_type	varchar(10) NOT NULL,
  order_no			tinyint(3) unsigned,
  value				varchar(100) NOT NULL,
  display			varchar(255),
  img				varchar(255),
  checked_ind		varchar(1),
  PRIMARY KEY ( s_attribute_type, value )
) TYPE=MyISAM COMMENT='Lookup table for System Attributes';

This table contains lookup data for entry fields.  For input_types of TEXT, HIDDEN or TEXTAREA
this table will be ignored.  The data from this table will also be used when formatting the 
insert/update value for attribute modifications.

The value column is what will actually go into the database.  If the display is null, then value
will be used for display as well.  The display column is what people will actually see in the
input field.  Certain input_type's support the use of images when displaying input fields.  The
img column should display an image url relative to the images/ directory.

The checked_ind column will be used to CHECK/SELECT a default value for a lookup input field.
This is of course only when a value does not exist in the database already.  Obviously for
input_types like CHECKBOX_GRID which support multiple CHECKED, then more than one
checked_ind can be set to "Y".

Note: the order_no in the s_item_type_lookup is NOT related to the s_item_attribute_type
order_no column.  The order_no has a maximum value of 256, which effectively limits the 
number of lookup values for a specific s_attribute_type to 256.

The s_item_attribute_type table
===============================

CREATE TABLE s_item_attribute_type (
  s_item_type		varchar(10) NOT NULL,
  s_attribute_type	varchar(10) NOT NULL,
  order_no			tinyint(3) unsigned NOT NULL,
  prompt			varchar(30),
  compulsory_ind	varchar(1),
  PRIMARY KEY ( s_item_type, s_attribute_type, order_no )
) TYPE=MyISAM COMMENT='System Item and attribute link table';

This table links a set of s_attribute_type's to a s_item_type, with
a specific order, so they can be displayed exactly as required
on the form.  This will also affect any LOV's for search pages
and the display of stats, etc.

s_attribute_type/order_no
-------------------------
The s_attribute_type and order_no are used to uniquely identify a
attribute.  When loading certain attributes for use, the order_no
will not be used.  This is because there is only ever supposed to
be a single instance. This is not enforced, but any extra ones will
most likely be ignored.  For example, the the IMDB site attribute
(imdb_id) should only have one instance for any item.

The order_no has a maximum value of 256, so this means you cannot have more
than 256 instances of the same s_attribute_type for an s_item_type.  

Generally all the s_attribute_types should be uniquely identified by the
order_no only, so be careful.  In reality you should not have more than 256
visible attributes associated with an s_item_type.  All hidden attributes
as long as they appear once can use order_no 0

prompt
------
The prompt allows the override of the default prompt with a more
specific value pertaining to the particular item_type.

compulsory_ind
--------------
The compulsory_ind allows for the entry of specific attributes to be
enforced before any database update can occur.

The item_attribute table
========================

CREATE TABLE item_attribute (
  item_id			integer(10) unsigned NOT NULL,
  s_attribute_type	varchar(10) NOT NULL,
  order_no			tinyint(3) unsigned NOT NULL,
  attribute_val		text NOT NULL,
  update_on			timestamp(14) NOT NULL,
  PRIMARY KEY ( item_id, s_attribute_type, order_no )
) TYPE=MyISAM COMMENT='Attributes';


This table is where the actual attributes are stored.  The s_attribute_type/order_no 
will map to the s_item_attribute_type table, as will the item_id(s_item_type).

