Skip to content

Configuring Database Descriptor

Siminov Framework edited this page Dec 25, 2015 · 36 revisions

Database Descriptor is the one who defines the schema of database.

                       <!-- Design Of DatabaseDescriptor.xml -->

    <database-descriptor>

        <!-- General Database Descriptor Properties -->
            <!-- Mandatory Field -->
        <property name="database_name">name_of_database_file</property>

            <!-- Optional Field (Default is sqlite)-->
        <property name="type">type_of_database</property>

            <!-- Mandatory Field -->
        <property name="version">database_version</property>
			
            <!-- Optional Field -->
        <property name="description">database_description</property>

            <!-- Optional Field (Default is false) -->
        <property name="transaction_safe">true/false</property>
	
	    <!-- Optional Field (Default is false) -->
        <property name="external_storage">true/false</property>
		


        <!-- Entity Descriptor Paths Needed Under This Database Descriptor -->
            <!-- Optional Field -->
        <entity-descriptors>
            <entity-descriptor>full_path_of_entity_descriptor_file</entity-descriptor>
         </entity-descriptors>
	
    </database-descriptor>
                  <!-- Android Sample: DatabaseDescriptor.xml -->

    <database-descriptor>

        <property name="database_name">SIMINOV-CORE-SAMPLE</property>
        <property name="description">Siminov Core Sample Database Config</property>
        <property name="version">1</property>
        <property name="transaction_safe">true</property>

        <entity-descriptors>
            <entity-descriptor>Entity-Descriptors/Book.xml</entity-descriptor>
            <entity-descriptor>Entity-Descriptors/Lession.xml</entity-descriptor>
        </entity-descriptors>

    </database-descriptor>
                     <!-- iOS Sample: DatabaseDescriptor.xml -->

    <database-descriptor>

        <property name="database_name">SIMINOV-CORE-SAMPLE</property>
        <property name="description">Siminov Core Sample Database Config</property>
        <property name="version">1</property>
        <property name="transaction_safe">true</property>

        <entity-descriptors>
            <entity-descriptor>Entity-Descriptors/Book.xml</entity-descriptor>
            <entity-descriptor>Entity-Descriptors/Lession.xml</entity-descriptor>
        </entity-descriptors>

    </database-descriptor>
                      <!-- Windows Sample: DatabaseDescriptor.xml -->

    <database-descriptor>

        <property name="database_name">SIMINOV-CORE-SAMPLE</property>
        <property name="description">Siminov Core Sample Database Config</property>
        <property name="version">1</property>
        <property name="transaction_safe">true</property>

        <entity-descriptors>
            <entity-descriptor>Entity-Descriptors/Book.xml</entity-descriptor>
            <entity-descriptor>Entity-Descriptors/Lession.xml</entity-descriptor>
        </entity-descriptors>

    </database-descriptor>

Note: Application Developer can provide their own properties also, and by using following API's they can use properties.

  • Get Properties - [Android:getProperties | iOS:getProperties | Windows:GetProperties | JavaScript:getProperties]: It will return all properties associated with Database Descriptor.

  • Get Property - [Android:getProperty(Name-of-Property) | iOS:getProperty:Name-of-Property | Windows:GetProperty(Name-of-Property) | JavaScript:getProperty(Name-of-Property)]: It will return property value associated with property name provided.

  • Contains Property - [Android:containsProperty(Name-of-Property) | iOS:containsProperty:Name-of-Property | Windows:ContainsProperty(Name-of-Property) | JavaScript:containsProperty(Name-of-Property)]: It will return TRUE/FALSE whether property exists or not.

  • Add Property - [Android:addProperty(Name-of-Property, Value-of-Property) | iOS:addProperty:Name-of-Property value:Value-of-Property | Windows:AddProperty(Name-of-Property Value-of-Property) | JavaScript:addProperty(Name-of-Property, Value-of-Property)]: It will add new property to the collection of Database Descriptor properties.

  • Remove Property - [Android:removeProperty(Name-of-Property) | iOS:removeProperty:Name-of-Property | Windows:RemoveProperty(Name-of-Property) | JavaScript:removeProperty(Name-of-Property)]: It will remove property from Database Descriptor properties based on name provided.

Database Descriptor Elements

1. General properties about database
  • database_name*: Name of database. It is mandatory field. All database files (.db)'s will be placed under the this folder name.

Android Sample : Application data folder structure


![Siminov Sample Application Data Folder Structure] (https://raw.github.com/Siminov/core/docs/github/v2.0/app_database_structure.android.png "Siminov Core Sample Application Data Folder Structure")


iOS Sample : Application data folder structure


![Siminov Sample Application Data Folder Structure] (https://raw.github.com/Siminov/core/docs/github/v2.0/app_database_structure.ios.png "Siminov Core Sample Application Data Folder Structure")


Windows Sample : Application data folder structure


![Windows Sample Application Data Folder Structure] (https://raw.github.com/Siminov/core/docs/github/v2.0/app_database_structure.windows.png "Windows Core Sample Application Data Folder Structure")


  • type: It defines the type of database. It is optional field. Default is sqlite.

  • version*: Version of database. It is mandatory field. This field is used for database upgradation.

  • descriptor: Description of database. It is optional field.

  • transaction_safe: TRUE/FALSE, Control whether or not the database is made thread-safe by using locks around critical sections.

This is pretty expensive, so if you know that your DB will only be used by a multi threads then you should set this to true.

The default is false. It is optional field.

Note

Siminov does not provide any security for database. If you want your database data needs to encrypted, then you can include SQLCipher implementation provided by Siminov framework in your application. For more detail see SQLCipher Encryption section of this developer guide.

  • external_storage: It specifies whether database resources needs to be saved on external storage or not (SDCard). It is optional field. Default is false.
2. Paths of entity descriptor needed under this database descriptor.

Note

  • Provide entity descriptor file path and name.
4. Important points about DatabaseDescriptor.xml

Note

  • You can specify any name for DatabaseDescriptor.xml file.

  • If any database folder is created, it will be on the name of database defined in DatabaseDescriptor.xml file.

Android Sample: DatabaseDescriptor.xml


![Android Sample - DatabaseDescriptor.xml] (https://raw.github.com/Siminov/core/docs/github/v2.0/database_descriptor_path.android.png "Android Sample - DatabaseDescriptor.xml")


iOS Sample: DatabaseDescriptor.xml


![iOS Sample - DatabaseDescriptor.xml] (https://raw.github.com/Siminov/core/docs/github/v2.0/database_descriptor_path.ios.png "Android Sample - DatabaseDescriptor.xml")


Windows Sample: DatabaseDescriptor.xml


![Windows Sample - DatabaseDescriptor.xml] (https://raw.github.com/Siminov/core/docs/github/v2.0/database_descriptor_path.windows.png "Windows Sample - DatabaseDescriptor.xml")