Rethink Files is a platform to organize, search and share files across any clouds.
The software supports multiple services like Figma, Gmail and Amazon S3. As a user I can connect my Rethink Files account with each of those services by entering specific credentials. Those connections are called Locations.
Each location has folders with sub-folders in it.
Specific folders of a Location can be favored. They appear below a section called Favorites.

- Credentials can be a username/password combination, OAuth credentials and so on. For this exercise it is sufficient to model just the entity.
- Modelling the folder hierarchy and file information is optional.
Solution
Schema

// Dropbox, Slack etc.
Table service {
id integer [primary key, not null, unique]
name char(128) [not null]
// OAuth between Rethink Files and e.g. Google Drive
client_id char(128) [not null]
client_secret char(128) [not null]
}
// a project can have multiple versions
Table account {
id integer [primary key, not null, unique]
name char(128) [not null]
}
// each account has multiple connected services
Table location {
id integer [primary key, not null, unique]
account_id int [not null, ref: > account.id]
// connection to the service
service_id int [not null, ref: > service.id]
// username, key
credential_token char(128) [not null]
// password, secret
credential_secret char(128) [not null]
}
// there are multiple ways to implement a folder hierarchy; this is a naive implementation
Table folder {
id integer [primary key, not null, unique]
// can be null as the root folder has no parent
parent_id integer [null, ref: > folder.id]
location_id integer [not null, ref: > location.id]
}
Table file {
id integer [primary key, not null, unique]
// can be null as the root folder has no parent
folder_id integer [not null, ref: > folder.id]
// for the sake of completeness, let's normalize the mime type
mime_type_id integer [not null, ref: > mime_type.id]
// filename
name char(255) [not null]
// "Date Modified"
modified_at datetime [not null]
// in bytes
size integer [not null]
}
Table mime_type {
id integer [primary key, not null, unique]
// e.g. application/pdf
name char(128) [not null]
// e.g. "PDF document"
description char(255) [not null]
}
Table favorite {
id integer [primary key, not null, unique]
// derived from the screenshot, favorites have a hierarchy
parent_id integer [null, ref: > favorite.id]
// a favorite points to a folder
folder_id integer [not null, ref: > folder.id]
// a custom name
name char(128) [not null]
}