You have two options for creating and populating a single dataset:
- Directly import a dataset from a file. In this case, the shape of your data file will define the shape of the dataset. The dataset fields are defined at the same time the dataset is populated during the data import process.
- Define dataset fields, then populate the dataset. Specify the shape of the dataset by adding fields to the dataset's definition. These fields correspond to the columns of the resulting dataset. After you have specified the name, key value and shape of the dataset, you can populate the dataset with data.
This page covers the second option and helps to you create a dataset by defining its schema and populating its fields.
Create a Dataset
You can create a single dataset schema by manually defining its fields. To get started:
- Click the Manage tab, then Manage Datasets.
- Click Create a New Dataset.
- Enter a Short Dataset Name for the dataset. Required.
- Optional: Enter a Dataset ID. The dataset ID is an integer number that must be unique for each dataset in a study. If you do not wish to specify a dataset ID (the usual case), simply leave the default "Define Dataset ID Automatically" checkbox checked.
- Do not check Import from File. You would use this option to upload a spreadsheet as a dataset (see: Create a Dataset from a File).
- Click Next.
Enter Dataset Properties
Enter dataset properties in the top section of the "Edit Dataset Definition" page. A full listing of options is available here: Dataset Properties
in the first section.
Define Dataset Fields
LabKey Server automatically includes standard system fields as part of every schema. These are the Dataset System Fields
You have two options for defining custom dataset fields:
- Option 1: Define dataset fields manually by adding fields in the "Dataset Fields" section of the page.
- Option 2: Import dataset fields by pasting a tab-delimited text file that describes the fields. Click the Import Fields button in the Dataset Fields section.
In the popup, paste tab-delimited text with the following column headers and one row for each field:
- Property (aka "Name") - Required. This is the field Name for this Property (not the dataset itself). The name must start with a character and include only characters and numbers
- Format - Optional. Set the format for Date and/or Number output. See Date and Number Formats Reference for acceptible format strings.
- RangeURI - This identifies the type of data to be expected in a field. It is a string based on the XML Schema standard data type definitions. The prefix "xsd" is an alias for the formal namespace http://www.w3.org/2001/XMLSchema# , which is also allowed. The RangeURI must be one of the following values:
- xsd:int – integer
- xsd:double – floating point number
- xsd:string – any text string
- xsd:dateTime – date and time
- xsd:boolean – boolean
- Label - Optional. Name that users will see for the field. It can be longer and more descriptive than the Property Name.
- NotNull (aka "Required") - Optional. Set to TRUE if this value is required. Required fields must have values for every row of data imported.
- Hidden - Optional. Set to TRUE if this field should not be shown in default grid views
- LookupSchema - Optional. If there is a lookup defined on this column, this is the target schema
- LookupQuery - Optional. If there is a lookup defined on this column, this is the target query or table name
- Description - Optional. Verbose description of the field
Import Data Records
After you enter and save a dataset definition, you will see the property page for your new Dataset. From here you can Import Data Records Via Copy/Paste
by selecting the "Import Data" button.
Edit Dataset Properties
In addition to importing data, you can also Edit Dataset Properties