
Importing sample data
The first thing we need to do in order to begin developing data models in SAP HANA is to import some sample tables and data. Some data has been prepared for this book, which will enable us to use all the features of the SAP HANA Studio and develop a reporting application. You don't have to use the sample data if you don't want to; you can follow the examples in the book using your own data if you prefer. However, if you use the data that's been prepared, you'll be able to see the example application unfold, using the different functionalities that SAP HANA provides.
Tip
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
This sample data will allow us to build a large range of data models, and will show the different features available in SAP HANA and SAP HANA Studio. The notion of speed of execution will not be covered; if we wanted to stress-test the database, we'd need millions of lines in tens of tables, which would not be feasible from a development perspective. If you need to test the performance of SAP HANA, please feel free to do so on a large dataset you prepare with your own data, or data you acquire freely from the Internet.
Note
The data used in Chapter 1, So, What Is This SAP HANA Thing Anyways?, to show SAP HANA's performance (information on commercial flights in the USA) can be acquired by download, contact the author directly by e-mail for the download link. Please bear in mind that the download size is over 5 GB, and represents nearly 50 GB of files on the disk, not counting the size taken by the data once loaded into SAP HANA.
The data prepared for this book represents the Revenue by Customer over three Years. Each customer is assigned to a Sector (large, small, or tiny customers), and a Country. Countries have been organized into Regions (the UK is in Europe, for example). The textual representations of the different objects are available in the data in different languages (English and French) represented by the Lang
field. Additionally, each table has a field called MANDT
. This field will be familiar to SAP ERP developers, as it represents the notion of session client or instance, where one given SAP ERP machine can have multiple instances of the software running at once, on the same database. The MANDT
field allows for data from different instances to be kept separate.
Once the archive has been uncompressed, you will be provided with a folder structure containing the tables, their data, and the information SAP HANA needs to correctly recreate the information, as shown in the following screenshot:

Inside the index
folder is a folder called BOOK
, which is the name of the database schema. Inside this folder are the seven tables; each table is represented by a folder, inside of which are several files describing the design of the table, its contents, and other metadata used by SAP HANA. We'll be importing this information into our SAP HANA server in a moment, but let's first take a look at how these data files were created.
SAP HANA object export
Note
This section deals with exporting data from SAP HANA. You don't need to do any of the actions in this section, they are just listed for reference, in case you need to use the export function later in your own developments.
This directory structure was created automatically by the SAP HANA Studio's Export functionality. This function allows the creation—either on the HANA server or on the local PC—of files representing the contents of the SAP HANA system.
The Export function can be called either from the Quick Launch panel (Content | Export), or from the menu (File | Export). The first thing to select is the type of object to be exported from the large selection of object types provided by the Studio, as shown in the screenshot:

Several of the export options shown in the screenshot are provided by the Eclipse tool, while others (the SAP HANA Content
and SAP HANA Studio
folders) are specific to SAP HANA. In order to export tables and their data the option used was Catalog Objects. This option allows export of tables, schemas, and database views (but not SAP HANA modeling objects).
The names of the objects to be exported need to be selected next. These have to be selected by name using the text field at the top of the following dialog box:

We can see in the screenshot that a search was done for all objects containing the word "book". The only matching object was the BOOK schema, and once it was added to the Selected Objects list, the Studio proposed to export the schema and all of its subobjects (this can be seen by the asterisk).
The final stage in the export process is the destination selection:

As we can see in the screenshot, export can be done either to the SAP HANA server or to the local PC, in either the CSV or BINARY format. The BINARY export is easier for SAP HANA to re-use on import, and takes up slightly less space in the data files. The CSV format, however, is easier to use outside of SAP HANA, as files of this type can be opened in many different tools, such as Microsoft Excel.
Export to the local PC can only be done on limited quantities of data. If there is too much data, the export will fail. If this happens, export to the server and then transfer the files to the local PC.
Importing exported data into SAP HANA
Once data has been exported from one SAP HANA instance, it can easily be imported into another. We'll be using this function here to import the sample data we downloaded earlier.
The Import function can be launched, just like the Export function, either from the Quick Launch panel or from the menu (Content | Import or File | Import, as appropriate).
The first screen of the Import dialog is identical to the first screen of the Export dialog we saw earlier. This screen allows us to select the type of data we are importing. As in the previous section, we are importing Catalog Objects.
On the second screen of the dialog, we choose the location containing the data to be imported, as we can see here:

The folder to select is the one that contains the index
subfolder. By selecting this level, the Studio will be able to detect the schema name and the table names. Once we click on Next, the Studio will present us with a list of importable objects in the selected folder, and we can choose those we wish to import:

In order to use the sample data for the examples in this book, select all the tables in the Matching items list, and click on Add to add them to the Selected Catalog Objects list. Click on Next to go to the following screen, where we can choose whether to import just the description of the tables (Catalog Only) or the table contents as well (Catalog and data – this is the option we need). Click on Finish to run the import.
The import itself will only take a couple of seconds, and once it's done, just refresh the Navigator panel (by clicking on the server name and then pressing the F5 key) to see the new BOOK schema under the Catalog node, and then the tables we just imported listed under the Tables node. The result should look similar to this screenshot:
