Skip to Content
Previous

Create a Database Module

By Lsubatin

Create database objects and CDS views

You will learn

You will create a database module with Core Data Services artifacts.

Details


Step 1: Create a database module

Back to your project, right click on your project and then click on New->SAP HANA Database Module:

create db

Name your module db and click on next

create db

Remove the namespace, add a name to the schema, click on Build module after creation and the click on Finish

create db
Please log in to access this content.
Step 2: Create a CDS artifact

You will now use Core Data Services to create a table. You will then use other entities to combine the data.

Begin by creating a folder under db->src:

create folder

Call it data:

create folder

Create a CDS artifact in your new folder

create folder

Call it PO

create folder
Please log in to access this content.
Step 3: Create your Entities using the CDS graphical editor

You can now explore the graphical Core Data Services editor briefly.

Click on an entity and drop it in the editor:

create CDS graphical

Call it APPROVAL_STATUS:

create CDS

Double click on the node you have just added (inside the white rectangle) and click on the + sign to add a new field for your entity:

add fields

Create two fields as follows:

create CDS fields

Save and close the Graphical editor.

Open the Text Editor again by right-clicking on PO.hdbcds

see text editor

Copy the definition of the entity (blurred out below) and click on Validate:

see text editor
×
Step 4: Load data into your entity

You will now add data into your new entity. Build the db module first:

Build db

Create a comma-separated values file called status.csv in the data folder:

create csv

Add the following contents to it:

ID,TEXT
I, In process
A, Approved
R, Rejected

Save the file.

create csv

Now you need to add a new file to indicate how that file loads your new table. Create a file called load.hdbtabledata

create csv

Add the following contents to it:

{
    "format_version": 1,
    "imports": [
        {
            "target_table": "PO.APPROVAL_STATUS",
            "source_data": {
                "data_type": "CSV",
                "file_name": "status.csv",
                "has_header": true
            },
            "import_settings": {
                "import_columns": [
                    "ID",
					          "TEXT"
                ]
            }
        }
    ]
}     

Save:

load csv

Build the module.

Build module

Save and build the db module. Wait until the build finished to answer the following question.

Which sentence resembles the build results the most?
×

Updated 10/20/2017

Time to Complete

15 Min

Beginner

Tags

Next
Back to top