Mapping individual fields
Tangram's persistent type system is extensible, allowing you to mount your own types and make them persistent. All you have to do is to register your type and provide mapping code. See Tangram::Type::Extending.
Tangram comes with built-in support for the following types:
Supported are strings, integers, real numbers and dates. More types of this ilk are easily added. \*(C`string\*(C', \*(C`int\*(C', \*(C`real\*(C': see Tangram::Type::Scalar \*(C`date\*(C', \*(C`time\*(C', \*(C`datetime\*(C', \*(C`dmdatetime\*(C': see \*(L"Date/Type/Date/DateTime\*(R" in Tangram::Type
\*(C`perl_dump\*(C': see Tangram::Type::Dump::Perl. A \*(C`perl_dump\*(C' structure may contain any structure which Data::Dumper can dump successfully. \*(C`storable\*(C': see Tangram::Type::Dump::Storable. Very much like \*(C`perl_dump\*(C', but implemented via the `Storable' serialisation engine. \*(C`yaml\*(C': see Tangram::Type::Dump::YAML. Very much like \*(C`perl_dump\*(C', but implemented via the `\s-1YAML\s0' serialisation engine. Doesn't currently work, due to inadequacies in the current Perl \s-1YAML\s0 implementation. \s-1NEW\s0 in Tangram 2.08: \*(C`idbif\*(C': see Tangram::Type::Dump::Any. Like the above, but can combine multiple object properties into a single database column.
Note: these are only actually required if you need to be able to query on individual fields inside the array/hash - otherwise, the \*(C`perl_dump\*(C' or \*(C`idbif\*(C' mapping is a lot faster and more flexible. \*(C`flat_array\*(C': see \*(L"Array/Scalar\*(R" in Tangram::Type \*(C`flat_hash\*(C': see \*(L"Hash/Scalar\*(R" in Tangram::Type
\*(C`ref\*(C': see Tangram::Type::Ref::FromMany (implementing an N to 1 relationship, in which any object can be the referant)
Set relationships are closest to the main type of relationship used in an \s-1RDBMS\s0. Avid CompSci students will know that the relational database model is based heavily on `Set Theory', which is a subset of a more general concept of `Categories' - generic couplings of a number of classes. In Perl space, these collections are represented via the Set::Object module. Sets may not have duplicate elements, and cannot contain undef values. \*(C`set\*(C': see Tangram::Type::Set::FromMany (implementing an unordered N to N relationship, with all objects sharing a common base class) \*(C`iset\*(C': see Tangram::Type::Set::FromOne (implementing an unordered 1 to N relationship, with all objects sharing a common base class)
The addition to Sets, you can have `Arrays' of objects, represented by a standard Perl array in memory. Arrays may contain undef values (in the middle of the list), and the \*(C`array\*(C' type may contain duplicates (ie, the same element present in separate places in the list). \*(C`array\*(C' : see Tangram::Type::Array::FromMany (implementing an ordered N to N relationship, with all objects sharing a common base class) \*(C`iarray\*(C': see Tangram::Type::Array::FromOne (implementing an ordered 1 to N relationship, with all objects sharing a common base class)
Much like the Array types, the Hash types are indexed via a string value, and represented as a Perl hash in memory. These hashes may not contain undef values (those are dropped). The \*(C`hash\*(C' type may contain duplicate elements. \*(C`hash\*(C' : see Tangram::Type::Hash::FromMany (implementing a keyed N to N relationship, with all objects sharing a common base class) \*(C`ihash\*(C': see Tangram::Type::Hash::FromOne (implementing a keyed 1 to N relationship, with all objects sharing a common base class)