Attributes

Attributes

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 primary 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:

Database column types to attribute types

Attribute typeUnderlying 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

image
  • 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

image
  • Number The default view option for number attributes.
  • Checkbox Will represent 0s as unchecked and other numbers as being checked. If checking an unchecked value, the value will be set to 1.

Primary 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 primary 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.

image

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.

image
image

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 primary attributes become useful within Basedash.

Primary attributes

In Basedash, we allow you to specify columns as primary attributes. Values in the primary 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 primary attribute on the users table to be email and a primary attribute on the teams table to be name. Notice how to column header icon changes to indicate the column is now the primary attribute.

image
image

Now, our team_members table will show the primary 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.

image

Primary attribute columns will be sticky columns that will stick to the left side of a table layout, even when scrolling horizontally. If no primary attribute is set on a table, the sticky column will be the primary key column on the table.

Manually set primary attributes

To mark a column as a primary attribute, you can right click on the column header in table layout and select the option “Set as primary attribute”.

image

You can also change the primary attribute of a table by navigating to the table settings for a data source and selecting the primary attribute from a dropdown.

image

Automatically set primary attributes

By default, Basedash will automatically mark a column as a primary 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 primary attribute.

💠
https://www.basedash.com

© BaseDash Inc.