function expandObjectAttributesAttribute( RecordSet $recordSet, Attribute $attributeToExpand, Attribute $objectIdAttribute, ViewInformation $viewInformation ) {
	$o = OmegaWikiAttributes::getInstance();
		
	$recordSetStructure = $recordSet->getStructure();
	$recordSetStructure->addAttribute( $attributeToExpand );
	
	foreach ( $viewInformation->getPropertyToColumnFilters() as $propertyToColumnFilter )
		$recordSetStructure->addAttribute( $propertyToColumnFilter->getAttribute() );
			
	$objectAttributesRecordStructure = $attributeToExpand->type;
	$objectIds = getUniqueIdsInRecordSet( $recordSet, array( $objectIdAttribute ) );
	
	if ( count( $objectIds ) > 0 ) {
		for ( $i = 0; $i < count( $objectIds ); $i++ )
			if ( isset( $objectIds[$i] ) ) {
				$record = new ArrayRecord( $objectAttributesRecordStructure );
				$objectAttributesRecords[$objectIds[$i]] = $record;
			}

		// Defined meaning attributes		
		$allDefinedMeaningAttributeValuesRecordSet = getDefinedMeaningAttributeValuesRecordSet( $objectIds, $viewInformation );
		$definedMeaningAttributeValuesRecordSets =
			splitRecordSet(
				$allDefinedMeaningAttributeValuesRecordSet,
				$o->relationType
			);
			
		$emptyDefinedMeaningAttributesRecordSet = new ArrayRecordSet( $allDefinedMeaningAttributeValuesRecordSet->getStructure(), $allDefinedMeaningAttributeValuesRecordSet->getKey() );
		
		// Text attributes		
		$allTextAttributeValuesRecordSet = getTextAttributesValuesRecordSet( $objectIds, $viewInformation );
		$textAttributeValuesRecordSets =
			splitRecordSet(
				$allTextAttributeValuesRecordSet,
				$o->textAttributeObject
			);
			
		$emptyTextAttributesRecordSet = new ArrayRecordSet( $allTextAttributeValuesRecordSet->getStructure(), $allTextAttributeValuesRecordSet->getKey() );
		
		// Translated text attributes	
		$allTranslatedTextAttributeValuesRecordSet = getTranslatedTextAttributeValuesRecordSet( $objectIds, $viewInformation );
		$translatedTextAttributeValuesRecordSets =
			splitRecordSet(
				$allTranslatedTextAttributeValuesRecordSet,
				$o->attributeObject
			);
			
		$emptyTranslatedTextAttributesRecordSet = new ArrayRecordSet( $allTranslatedTextAttributeValuesRecordSet->getStructure(), $allTranslatedTextAttributeValuesRecordSet->getKey() );

		// Link attributes		
		$allLinkAttributeValuesRecordSet = getLinkAttributeValuesRecordSet( $objectIds, $viewInformation );
		$linkAttributeValuesRecordSets =
			splitRecordSet(
				$allLinkAttributeValuesRecordSet,
				$o->linkAttributeObject
			);
			
		$emptyLinkAttributesRecordSet = new ArrayRecordSet( $allLinkAttributeValuesRecordSet->getStructure(), $allLinkAttributeValuesRecordSet->getKey() );
		
		// Option attributes		
		$allOptionAttributeValuesRecordSet = getOptionAttributeValuesRecordSet( $objectIds, $viewInformation );
		$optionAttributeValuesRecordSets =
			splitRecordSet(
				$allOptionAttributeValuesRecordSet,
				$o->optionAttributeObject
			);
			
		
		$emptyOptionAttributesRecordSet = new ArrayRecordSet( $allOptionAttributeValuesRecordSet->getStructure(), $allOptionAttributeValuesRecordSet->getKey() );
		
		for ( $i = 0; $i < $recordSet->getRecordCount(); $i++ ) {
			$record = $recordSet->getRecord( $i );
			$objectId = $record->getAttributeValue( $objectIdAttribute );
			
			// Defined meaning attributes
			if ( isset( $definedMeaningAttributeValuesRecordSets[$objectId] ) )
				$definedMeaningAttributeValuesRecordSet = $definedMeaningAttributeValuesRecordSets[$objectId];
			else
				$definedMeaningAttributeValuesRecordSet = $emptyDefinedMeaningAttributesRecordSet;

			// Text attributes
			if ( isset( $textAttributeValuesRecordSets[$objectId] ) )
				$textAttributeValuesRecordSet = $textAttributeValuesRecordSets[$objectId];
			else
				$textAttributeValuesRecordSet = $emptyTextAttributesRecordSet;

			// Translated text attributes
			if ( isset( $translatedTextAttributeValuesRecordSets[$objectId] ) )
				$translatedTextAttributeValuesRecordSet = $translatedTextAttributeValuesRecordSets[$objectId];
			else
				$translatedTextAttributeValuesRecordSet = $emptyTranslatedTextAttributesRecordSet;

			// Link attributes
			if ( isset( $linkAttributeValuesRecordSets[$objectId] ) )
				$linkAttributeValuesRecordSet = $linkAttributeValuesRecordSets[$objectId];
			else
				$linkAttributeValuesRecordSet = $emptyLinkAttributesRecordSet;

			// Option attributes
			if ( isset( $optionAttributeValuesRecordSets[$objectId] ) )
				$optionAttributeValuesRecordSet = $optionAttributeValuesRecordSets[$objectId];
			else
				$optionAttributeValuesRecordSet = $emptyOptionAttributesRecordSet;

			$objectAttributesRecord = new ArrayRecord( $objectAttributesRecordStructure );
			$objectAttributesRecord->objectId = $objectId;
			$objectAttributesRecord->relations = $definedMeaningAttributeValuesRecordSet;
			$objectAttributesRecord->textAttributeValues = $textAttributeValuesRecordSet;
			$objectAttributesRecord->translatedTextAttributeValues = $translatedTextAttributeValuesRecordSet;
			$objectAttributesRecord->linkAttributeValues = $linkAttributeValuesRecordSet;
			$objectAttributesRecord->optionAttributeValues = $optionAttributeValuesRecordSet;
			
			$record->setAttributeValue( $attributeToExpand, $objectAttributesRecord );
			applyPropertyToColumnFiltersToRecord( $record, $objectAttributesRecord, $viewInformation );
		}
	}
}
	/** 
	 * Load the associated record object.
	 *
	 * @return Boolean indicating success.
	 */
	public function loadRecord() {

		if ( is_null( $this->exists ) ) {
			$this->checkExistence();
		}

		if ( !$this->exists ) {
			return false;
		}

		$id = $this->getId();
		$view = $this->getViewInformation();
		/** FIXME: Records should be loaded using helpers rather than
		  global functions! */
		$o = OmegaWikiAttributes::getInstance();

		$record = new ArrayRecord( $o->definedMeaning->type );
		$record->definedMeaningId = $id;
		$record->definedMeaningCompleteDefiningExpression =  getDefiningExpressionRecord( $id );
		$record->definition = getDefinedMeaningDefinitionRecord( $id, $view );
		$record->classAttributes = getClassAttributesRecordSet( $id, $view );
		$record->alternativeDefinitions = getAlternativeDefinitionsRecordSet( $id, $view );
		$record->synonymsAndTranslations = getSynonymAndTranslationRecordSet( $id, $view );
		$record->reciprocalRelations = getDefinedMeaningReciprocalRelationsRecordSet( $id, $view );
		$record->classMembership = getDefinedMeaningClassMembershipRecordSet( $id, $view );
		$record->collectionMembership = getDefinedMeaningCollectionMembershipRecordSet( $id, $view );
		$objectAttributesRecord = getObjectAttributesRecord( $id, $view );
		$record->definedMeaningAttributes = $objectAttributesRecord;
		applyPropertyToColumnFiltersToRecord( $record, $objectAttributesRecord, $view );
		
		$this->record = $record;
		$this->recordIsLoaded = true;
		return true;
	}