The role of metadata (metadata) in enterprise application development

Source: Internet
Author: User
Tags define
Data
The role of metadata (metadata) in enterprise application development

Meta data (metadata) Introduction:
Metadata (metadata), which is the data about data, has been widely used in software design in recent years Metadata.
In programming, metadata is not an object to be processed, but rather changes the data of the program's running by changing some "values" of the metadata.
You can "interpret" the runtime of a program, and different metadata values allow the same program to have different running results.
Meta-data (metadata) applications:



In the previous work, often encountered such a problem,



A table in the SQL Server database is as follows:



CREATE TABLE [dbo]. [Dprofile] (



[profile_id] [INT] IDENTITY (1, 1) not NULL,



[ProfileName] [varchar] (COLLATE) Chinese_prc_ci_as NULL,



[Otherinfo] [varchar] (m) COLLATE chinese_prc_ci_as NULL,



[Validatestatus] [INT] Null



) on [PRIMARY]



Define an entity class for it:



Namespace E_commerce.data



{



<summary>



Card Properties Basic Information entity



</summary>



public class Dprofileinfo



{



<summary>



Other information



</summary>



public string Otherinfo



{



Get



{



/*begin Template



return motherinfo;



/*end Template expansion{9d774738-e901-427a-86e7-ef2715768c17}*/



}



Set



{



/*begin Template expansion{f6a2b75d-d01b-47b0-b65d-e62e43286ddc}*/



Motherinfo = value;



/*end Template expansion{f6a2b75d-d01b-47b0-b65d-e62e43286ddc}*/



}



}



<summary>



Card Property ID



</summary>



public int profile_id



{



Get



{



/*begin Template expansion{2230d3c4-9766-4778-9203-5063d88b468c}*/



return mprofile_id;



/*end Template expansion{2230d3c4-9766-4778-9203-5063d88b468c}*/



}



Set



{



/*begin Template expansion{0a1c9514-4ddb-4079-be19-8dace24cd454}*/



mprofile_id = value;



/*end Template expansion{0a1c9514-4ddb-4079-be19-8dace24cd454}*/



}



}



<summary>



Card Property Name



</summary>



public string ProfileName



{



Get



{



/*begin Template expansion{a43788b8-60a0-4882-9c51-a3dee710fe78}*/



return mprofilename;



/*end Template expansion{a43788b8-60a0-4882-9c51-a3dee710fe78}*/



}



Set



{



/*begin Template expansion{829eef0a-a18a-4492-be57-67c4c57acfc3}*/



Mprofilename = value;



/*end Template expansion{829eef0a-a18a-4492-be57-67c4c57acfc3}*/



}



}



private string Motherinfo;



private int mprofile_id;



private string Mprofilename;



}



}
This often happens during development and actual operation, and after a period of time the user's actual situation changes, you may want to add one or more fields to the table in the entity above and the database that corresponds to it. We can only modify this data entity, and after the code development is complete, making such modifications is cumbersome and potentially dangerous.



Imagine the current situation, for various reasons need to change the above data structure, we intend to add two fields "Price" "Createtime", there is any way to make the data entity easy to adapt to this change?



Two ways:



1 Add a description of the added field in table Dprofile the name of the metadata field is Fieldsmetainfo, and the data type can be defined as a text type or a binary type such as image. In this field, define an XML-formatted document description and store the newly added field.



The format may be like this



<field name= "Price" frombasetype= "TRUE" type= "Text" displayname= "Prices" required= "TRUE" maxlength= "255" defaultvalue= "0" >123.45</Field>



<field name= "Createtime" frombasetype= "true" type= "Datetiem" displayname= "Price" required= "true" >2004-01-01</ Field>



This newly added field records other information such as data type information and data information that may be added to the field in the future.



2) Add two tables



Store newly added field information in a table



Table Profilefields



ID int



FieldName nvarchar (50)



FieldType nvarchar (50)



Table Profilefieldsvalue



ID int



profileID int



Profilevalue varchar (50)



Profilefields table stores additional field name types and other information



Table Profilefieldsvalue table stores values corresponding to filed







Adding a property of a custom type in the data entity class returns the data stored in the source data structure



Can be a Hashtable type, or it can be a custom other collection type



Private Hashtable metafieldslist;



Custom architecture for easy storage and updating








Meta-data (metadata) data storage structure:
Metadata has many storage formats, most of which are in XML format.
XML is best used for storing metadata, easy to use and parse.

The role of metadata (metadata) in O-r mappings:










Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.