-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Additional tutorials #925
Comments
Hey @cabaucom376 thanks for opening this issue. I think the explanation given here(https://discord.com/channels/902568124350599239/1264072571188416512/1292768116417495084) covers most of the current capabilities for namespaces and how it relates to user access. However as an action point I'll expand the Namespace & Database concept doc https://surrealdb.com/docs/surrealdb/introduction/concepts/namespace to answer some of your questions.
RE your above question: Think of namespaces as organisations housing databases. So you can have multiple databases under the same namespace. On the database level, you can then specify access. You can also have Namespace users(sys admins) that have access to these databases so conflict would be avoided automatically because you'd have to also specify what database you want to query against. Can you explain more on Storing metadata? You can access this information using the INFO statement: Getting a list of all users and their permissions and all the databases within the specified namespace. Think of it like so Root users have access to all Namespace and databases Namespace users have access to all databases Database user have access to their assigned database. |
Thanks @Ekwuno, So I kind of get the idea of the hierarchy and how the two features interact, but I am struggling to understand how I can utilize the data separation that those tools provide in a collaborative environment. If I want Users to have individual Workspaces where each contains tables that are separate from another, it makes sense to me that I would achieve that via
I did forget about the INFO and DEFINE USER statements so thank you for that, I'll have to do some more deliberation on how to use those. As far as what I meant by metadata, say that I wanted to have a description, last_modified, etc... defined for the workspace |
Is your feature request related to a problem?
I've noticed a lack of high-quality content on best practices for architecting databases with SurrealDB. My aim is to enhance the tutorial section with more robust, real-world examples and explanations.
I believe the Namespace and Database features are under-documented and can be confusing to implement. This is particularly true for multi-tenancy, where most available content consists of vague answers from the SurrealDB team. While the core concepts are outlined, applying these concepts to a real-world database architecture raises questions on best practices.
Example of current considerations:
I'm developing a system where a
User
can have multipleWorkspaces
, each fully isolated for privacy. Users can upload theseWorkspaces
to a central server for collaboration, with permissions defined by the owner. Here are the approaches I'm considering:Single Namespace/Database: All data is stored within a single Namespace and Database. While functional with appropriate schemas, this raises security concerns in a server environment, especially with deeply nested hierarchical data shared across users. Scalability also becomes a point of concern.
Users as Namespaces, Workspaces as Databases: Each user gets a Namespace, with each Workspace stored in a separate Database. However, this approach raises several challenges:
$param
doesn’t work withDEFINE
statements?Workspaces as Namespaces, Users as Tables: In this model, Users are stored in a table, with one marked as the owner of each Workspace. But how can we dynamically create new Namespaces given the limitations of
$param
withDEFINE
statements?Describe the solution:
The solution is to create new tutorials that dive into practical use cases for SurrealDB's Namespaces and Databases. These tutorials would provide clear, step-by-step guides on implementing multi-tenancy, securing user data, and dynamically managing Databases.
One tutorial could explore how to structure a multi-tenant SaaS application where each user's data is isolated within its own Namespace and Workspace. It would cover dynamic Namespace and Database creation, managing user access permissions, and organizing global metadata efficiently.
These tutorials would give developers a concrete roadmap for applying SurrealDB's features to real-world applications, reducing confusion and enhancing confidence in building secure, scalable architectures.
Alternative methods:
I considered creating a YouTube tutorial series to visually demonstrate SurrealDB’s Namespaces and Databases. While this could offer a more hands-on approach, written tutorials within the documentation would be more accessible for developers who prefer detailed, text-based references for easy copy-pasting and following along at their own pace.
Contact Details
[email protected]
Is there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: