Connection guides
Attributes
Basedash uses the terms attributes over columns
Why not use the term “columns”?
Basedash doesn’t use the term columns, but instead uses the term attributes when referencing database columns. This is because Basedash plans include other data source types than SQL databases in the future. If we were to support MongoDB and Firebase data sources to be connected to Basedash, the concept of columns doesn’t exist in MongoDB or Firebase. However, we would still like to be able to let users setup display attributes (see below) on their MongoDB or Firebase data sources.
Attribute types
Basedash converts underlying database column types to one of the following attribute types:
- Text
- JSON
- Number
- Boolean
- Datetime
- Date
- Time
- Array
- Foreign key
By default, the attribute type is Text. If the database column represents a foreign key, the type will be Foreign key. Otherwise, see the following mapping of database column type to attribute type:
Attribute type | Underlying database column type |
---|---|
JSON | jsonjsonb |
Number | tinyintsmallintintintegermediumintbigintdecimaldoublefloatnumericrealdouble precisionsmallserialserialbigserialmoney |
Boolean | booleanbit |
Datetime | datetimetimestamptimestamptz |
Date | date |
Time | time |
Array | array |
Attribute view options
Depending on the attribute type, you can choose to view the data differently within Basedash.
Text attributes
- Text The default view option for text attributes.
- Rich text If your text is written as HTML or markdown, then Basedash will be able to do things such as show bold and italicized text, lists, and more.
- JSON A JSON editor will be used and proper syntax highlighting will be used.
- Image If the text value is a URL, then Basedash will display the image corresponding to that URL if the “Image” view option is selected.
Number attributes
- Number The default view option for number attributes.
- Checkbox
Will represent
0
s as unchecked and other numbers as being checked. If checking an unchecked value, the value will be set to1
.
Display attributes vs primary keys
You may be familiar with primary keys, which are values in your database that are used to uniquely identify a record. Basedash introduces display attributes to allow your data to be more understandable when viewed in Basedash.
First, let’s explain what primary keys are used for in databases.
Primary keys
For example, let’s take the given database table for users.
The database table may have been setup to use the id
column as the primary key. This primary key can be used in the database when you want to reference a user from another table.
Let’s introduce two new tables to illustrate this: teams and team_members.
In the team_members table, the team_id
and user_id
columns are foreign keys pointing towards the teams and users tables, respectively. A foreign key is a column or a set of columns in a table whose values correspond to the values of the primary key in another table.
The team_members table isn’t really all that useful to look at by itself since you need to do a lot of cross referencing between the teams table and users table in order to figure out which team/user corresponds with the foreign key value in the team_id
/user_id
columns.
That’s where display attributes become useful within Basedash.
Display attributes
In Basedash, we allow you to specify columns as display attributes. Values in the display attribute columns will be used in the Basedash UI to represent foreign key values, instead of the primary key.
Continuing with our example from above, let’s set a display attribute on the users table to be email
and a display attribute on the teams table to be name
. Notice how to column header icon changes to indicate the column is now the display attribute.
Now, our team_members table will show the display attribute values for the foreign keys that point to the users and teams tables, making the table more easily understandable without the need for cross-referencing table data.
Display attribute columns will be sticky columns that will stick to the left side of a table layout, even when scrolling horizontally. If no display attribute is set on a table, the sticky column will be the primary key column on the table.
Manually set display attributes
To mark a column as a display attribute, navigate to the table settings for a data source and select the display attribute from a dropdown.
Automatically set display attributes
By default, Basedash will automatically mark a column as a display attribute if it has one of the following names:
Name
Full name
First name
Username
Email
Title
The above names are ordered in priority, so if a table contains both Name
and Email
columns, the Name
column will be marked as the display attribute.