# Modify metadata

The metadata manager can be used to change the metadata of your tables, i.e., create tables (aka entityTypes), add, remove columns (aka attributes).

![Full Edit Overview](https://244515471-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi6GgXyV8c5eQm2AEdj1X%2Fuploads%2Fgit-blob-accaf5ac0f1fffd11c80a8ccff866d519870c8dd%2Ffull-edit-overview.png?alt=media)

This entails changing descriptions, changing the labels, changing the package in which the EntityType lives, but it also means you can add and remove attributes (columns), or even change the order in which they are shown in the data explorer.

The metadata manager also allows you to create new EntityTypes (tables) from scratch! No longer do you need to understand the EMX format and import excel sheets via the importer, you can create new data tables from scratch using the metadata manager user interface.

## Add table (create)

To create a new table (EntityType), press the blue 'plus' button next to the EntityType select dropdown.

![Entity Edit Form New](https://244515471-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi6GgXyV8c5eQm2AEdj1X%2Fuploads%2Fgit-blob-5648e4a20c284ce31a2d765863d47525c855d8b8%2Fentity-edit-form-new.png?alt=media)

You will get an empty template, allowing you to build your EntityType from scratch. If you are familiar with relational database concepts, you will probably recognize most of the inputs. In any case, here we will take you through the different fields and explain their use.

**Extends** : The extends dropdown lets you choose another EntityType which your EntityType will extend. This means that any attributes that EntityType might have, will be inherited by your EntityType.

An EntityType **has** to be abstract in order for you to extend it.

Abstract EntityType _Job_

\| Salary | Company name | |-----------------------|

Concrete EntityType _Doctor_

\| Patients | Working hours | |--------------------------|

Now, if _Doctor_ extends _Job_, you will get the following table

\| Salary | Company name | Patients | Working hours | |--------------------------------------------------|

**Abstract** : This switch will allow you to set your EntityType to abstract. Creating an abstract EntityType means that it will **not** contain any data. It is useful if you want to create multiple tables that share common attributes.

**Label** : Piece of text allowing you to set a human readable name for your EntityType.

**Description** : Piece of text describing your EntityType.

**Package** : Setting a Package allows you to group EntityTypes together under a single namespace. _Note_: Packages can not be created via the metadata manager, you have to create them either in the dataexplorer or upload them via the importer

**ID attribute** : The attribute that will serve as the ID, or primary key, within your EntityType.

**Label** : The label attribute will determine which attribute of an EntityType is shown when you search for values _in_ an EntityType.

**Lookup attributes** : The lookup attributes determine which columns are used to search when doing specific queries.

When talking about ID attributes and lookup attributes, you might wonder: where do I get these attributes? The answer is: in the Attribute tree!

![3](https://244515471-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi6GgXyV8c5eQm2AEdj1X%2Fuploads%2Fgit-blob-6532c611bdb8a158b8ced5b0eae625cf7825d3bd%2Fattribute-tree-new.png?alt=media)

The tree allows you to do three things:

* Create new attributes
* Remove existing attributes
* Change the order of attributes

For tutorials sake, I created three attributes: _id_, _label_, and _country_

Now we will add a new attribute. I click the blue plus button next to attributes.

![4](https://244515471-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi6GgXyV8c5eQm2AEdj1X%2Fuploads%2Fgit-blob-45fd8135bf7c5dc9fa32cd30de563acceb190863%2Fattribute-edit-form-new.png?alt=media)

just like with a new EntityType, you get an empty template. This gives you complete control on how you want your attribute to look like.

As you probably noticed, there are **a lot** of options to set. Luckily, we can get away with the default settings 50% of the time. For more advanced use cases, we explain the every input field below.

**Name** : A unique identifier for attributes _within_ this EntityType (You can have multiple 'id' attributes across different EntityTypes). Name your attributes wisely, because once they are created they cannot be renamed.

**Label** : A label for your attribute. This is meant to be a human readable name, and will be column names people see when they look at your data.

**Description** : A description for your attribute.

**Type** : Now the type field is a very important one. It determines which type of data will be allowed in this column. This can be strings and numbers, or more advanced types like dates, email, enum, or the very MOLGENIS specific xref or mref types. Some of the types will reveal extra fields on selection, we will go through these special fields now.

_Select int or long_ : Selecting a numerical type will give you the added options _minimum range_ and _maximum_ range. As the names suggest, it will allow you to set rules that number values in this column have to adhere to.

_Selecting categorical, categorical\_mref, xref, mref_ : These are partially MOLGENIS specific datatypes. What they have in common is that they allow an attribute to reference to another EntityType. You will have to set a 'reference entity'. This means that you have to select another EntityType.

_Selecting enum_ : Enums offer a set list of values. You can fill these in via a comma separated string e.g. _enumOption1,enumOption2,enumOption3_

_Selecting onetomany_ : They one to many type is a reference type that allows a backreference. Meaning that not only will you be able to look from A to B, but also from B to A. The mapped by and order by fields are now open to you. Mapped by is the same as an XREF, you select reference entity. Order by can be used to determine how your values are sorted, e.g country;ASC will sort the reference values on the country column in ascending order.

**Parent** : It is possible to nest an attribute under another attribute. The parent option shows you a dropdown with all the Compound attributes present in your EntityType.

**Nullable** : If a column can be empty or not

**Auto** : If the values should be auto generated or not. Mostly used for ID attributes

**Visible** : Should the column be visible or not. Also used to hide auto generated identifiers

**Unique** : Forces all values in this column to be unique. Automatically set for ID attributes.

**Read-only** : The values for this column can not be edited when checked.

**Aggregatable** : When checked, allows MOLGENIS to compute aggregation on the values of this attribute.

**Computed value expression** : Computes value for a column based on other columns.

For String type attributes, uses a string template, e.g.: `{"template": "Hello {{world.label}}"}` which fills in the value of the `label` attribute of the `world` reference.

For single reference type attributes, creates an instance of the refEntity type, copying attribute values. E.g.: `{Chromosome: foo, Position: bar}`

**Visible expression** : Expression that determines whether the column should be shown or not. e.g. `{A}` will only show column B when the value in A is truthy. Useful for one line datasets.

**Validation expression** : Expression that validates the values inside a column. e.g. `{A} > 5` will throw a validation error when you try to add data that is lower than 5

After you have created some attributes, selected an ID attribute, and feel comfortable with your EntityType, you can hit the 'Save all changes' button. If everything is correct, you will get a message saying save was successful. If something went wrong, you will get a message telling you which fields you forgot.

After saving, your new EntityType will be available in the dropdown for further editing, and you can start importing data for it via the importer.

## Change table (alter)

You can select existing table (EntityType) in the dropdown at the top of the screen

![5](https://244515471-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi6GgXyV8c5eQm2AEdj1X%2Fuploads%2Fgit-blob-e72c9a5f741a3982a0226032904b9e31ebc947dc%2Fheader-select-open.png?alt=media)

On select, all the fields that were visible for creating a new EntityType are available to you. After you are done changing things, you can hit the save all changes button.

### Conversion list of data types

This list describes the allowed conversion of data types in the metadata edit.

| Origin Attribute Type | Allowed conversions                                        |
| --------------------- | ---------------------------------------------------------- |
| BOOL                  | STRING, TEXT, INT                                          |
| CATEGORICAL           | STRING, INT, LONG, XREF, CATEGORICAL\_MREF, MREF           |
| CATEGORICAL\_MREF     | MREF, XREF, CATEGORICAL                                    |
| COMPOUND              | STRING                                                     |
| DATE                  | STRING, TEXT, DATE\_TIME                                   |
| DATE\_TIME            | STRING, TEXT, DATE                                         |
| DECIMAL               | STRING, TEXT, INT, LONG, ENUM                              |
| EMAIL                 | STRING, TEXT, XREF, CATEGORICAL                            |
| ENUM                  | STRING, INT, LONG, TEXT                                    |
| FILE                  | NONE                                                       |
| HTML                  | STRING, TEXT, SCRIPT                                       |
| HYPERLINK             | STRING, TEXT, XREF, CATEGORICAL                            |
| INT                   | STRING, TEXT, DECIMAL, LONG, BOOL, ENUM, XREF, CATEGORICAL |
| LONG                  | STRING, TEXT, INT, DECIMAL, ENUM, XREF, CATEGORICAL        |
| MREF                  | CATEGORICAL\_MREF, XREF, CATEGORICAL                       |
| ONE\_TO\_MANY         | NONE                                                       |
| SCRIPT                | STRING, TEXT                                               |
| STRING                | ALL                                                        |
| TEXT                  | ALL                                                        |
| XREF                  | STRING, INT, LONG, CATEGORICAL, MREF, CATEGORICAL\_MREF    |

## Delete table (drop)

If you want to remove an EntityType because you want to start over or had some experiments that are no longer necessary, you can go and select that EntityType and hit the big 'Delete entity' button
