GitHub    Download    Forum
Overview
Tutorial
Database setup
Preparing the project
Establish the connection
Shut down the connection
DTDL types
Creating the schema
DADL classes
Entry point object
Write and read attributes
Write and read lists
Extending the schema
Modified entry point object
Write and read objects
Write and read object lists
C++ API
C# API
DTDL
DADL
Setup

Extending the schema

Our situation now is that we want to extend our database from the first version to the next. We want to add an inventory to our system. We show how this can be done in the existing database without interfering with what we already have. This is one of the most exciting features of DataFS.

Data Type Definition

The new definitions that are required can be added by updating the existing DTDL file or by adding an additional new one to the project. That is what we will do. So, like before, click on "Add > New item…" and select the "DTDL file" from the DataFS folder. This time, we need another name. Let's call it "DataDefinitionEx.dtdl" for "Extension".
DataDefinitionEx.dtdl
namespace Tutorial
{
	class Inventory [id({FE438523-E2A1-48e6-A0C6-3A88B67A8FFF})]
	{
		object      Manager;
		ArticleList Items;
	};

	class Responsible [id({525372A2-EEBE-40A5-90D5-C7BC63FDC8D2})]
	{
		wstring FullName;
		wstring Comment;
	};

	class ShopArticle [id({AD643CA4-995D-42b5-9E31-A8482DD7B484})]
	{
		wstring ArticleName;
		uint16  Count;
	};

	list ArticleList [id({FA28CAE4-B97B-4783-85D2-1F746FA900E9}), ck]
	{
		object Article;
	};
}
Like we did with our first DTDL file, we will compile this and then add it to the schema using the DataFSTools.
Open-Connection
Extend-Schema -DomainGuid "{E9F56A1D-4FD9-483E-A4FE-7522666AB7C6}" -BDTD "-yourPath-\_data\DataDefinitionEx.bdtd"
Close-Connection
exit

Data Access Definition

Since we have new data types, we also need new access types. But unlike the situation with DTDL types and schema modifications, we can make as many changes as we want to DADL definitions. It only defines how we use the DTDL types right now. It is also entirely possible that more than one application is using the same DTDL type. In this case, they would still be very likely to use different DADL definitions.
AccessDefinition.dadl
#import <DataDefinition.bdtd>
#import <DataDefinitionEx.bdtd>

object WSupplies
{
	Tutorial::Supplies
	{
		Description	[get, set, remove];
		LastUpdated	[get, set];
		Shops		[get, set, remove];
	}
};

object WInventory
{
	Tutorial::Supplies
	{
		Description	[get, set, remove];
		LastUpdated	[get, set];
		Shops		[get, set, remove];
	}

	Tutorial::Inventory
	{
		Manager		[link(WResponsible), open(WResponsible)];
		Items		[get, set, remove];
	}
};

object WResponsible
{
	Tutorial::Responsible
	{
		FullName	[get, set];
		Comment		[get, set];
	}
};

object WShopArticle
{
	Tutorial::ShopArticle
	{
		ArticleName [get, set, remove];
		Count		[get, set];
	}
};

list ArticleList Tutorial::ArticleList
{
	Article			[link(WShopArticle)];
};
© 2022 Mobiland AG