Pel
Pel

Reputation: 13

How local is information in a database?

I've started practicing using databases with DiscordJS. I'm using the sequelize package and the SQLite dialect.

I wanted to confirm that with databases, there is no "locally stored information"; i.e information that is only accessible to one guild/server. I'm asking this because I want to set up server-specific settings for my bot, but if I store them in my database, they will be the same for all servers - so I'm not sure how to go about it. If the bot is currently running, can I just store the settings as variables in my code? If I do that, I'm worried about the settings being deleted when I take the bot down. So I'm not sure how to go about solving this issue.

Sorry if this is a silly question. I wasn't sure how to word it which made it really hard to find answers before coming here.

Upvotes: 0

Views: 27

Answers (1)

Quentin
Quentin

Reputation: 944171

I wanted to confirm that with databases, there is no "locally stored information"; i.e information that is only accessible to one guild/server.

All the data is stored in the file you use for SQLite.

Nothing about it is intrinsically associated with anything on Discord at all.

It is up to you to design a data structure suitable for your needs.

I'm asking this because I want to set up server-specific settings for my bot, but if I store them in my database, they will be the same for all servers

Only if you store them without associating them with a specific server.

Typically you would store information about the servers involved in a table and then use a foreign key on that table to associate things with (in a traditional one-to-many or many-to-many relationship).

Discord servers already have a unique id so you can make that the primary key in that table.

Upvotes: 1

Related Questions