Collection Definition Objects
A collection definition is meta data about specific kinds of collections. The collection definition object defines the characteristics of a collectionand provides a template to which a collection conforms.
Typically, a collection contains a set of identically structured objects. You can use a collection definition object to create object and relationship collections that provide your tool or application with a way to manipulate sets of objects and relationships as a single unit. An object collection is a set of similar objects. A relationship collection is a set of similar relationships.
In the following example, the right column (Data) lists some collections by name, while the kinds of collections are in the left column under Kind of Data. The Kind of Data column indicates the templates to which the items in the Data column must conform. Because the items in the Data column are collections, the items in the Kind of Data column are called collection types and they conform to a collection definition.
The most important way that a collection can conform to a collection definition is in its size. That is, a collection definition describes the size limitations on any collection conforming to it. In the following table, each instance of the collection definition publisher-of-book describes the collection of publishers of a particular book. A typical instance of this collection definition is publisher-of-Inside-OLE. In the table, each book has only one publisher.
The collection definition can define this restriction. That is, the publisher-of-book collection definition can impose a maximum size of one on each collection conforming to it. Similarly, the collection type can define a minimum size restriction.
The following list contains some other examples:
- Publisher-of-book (zero, one).
The minimum size is zero because not every book has a publisher. The maximum size is one because no book can have two or more publishers.
- Books-of-publisher (zero, many).
The minimum size is zero because a publisher can exist before it actually publishes any books. The maximum size is many because some publishers can publish more than one book.
- Books-of-person (zero, many).
The minimum size is zero because not every person is an author. The maximum size is many because some people can write more than one book.
- Authors-of-book (zero, many).
The minimum size is zero because the authors of some books are anonymous. The maximum size is many because more than one person can coauthor a book.
You can access a collection definition object from Automation or COM programs using the CollectionDef object, the CollectionDef class, or the ICollectionDef interface.