Design an RBAC Relational Schema
Company: Bytedance
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Technical Screen
Design a relational database schema for role-based access control (RBAC).
Your design should model the following concepts:
- **User**: a person or service account that can access the system.
- **Role**: a named grouping of permissions, such as `Admin`, `Editor`, or `Viewer`.
- **Permission**: an allowed action, such as `read`, `write`, `delete`, or `approve`.
- **Resource**: an object being protected, such as a document, project, repository, or account.
Explain:
1. The relationships among users, roles, permissions, and resources.
2. Which relationships are one-to-many versus many-to-many.
3. The tables you would create, including primary keys and foreign keys.
4. How you would answer the question: "Does user U have permission P on resource R?"
5. Any important constraints, indexes, or extensions you would consider for a production system.
Quick Answer: This question evaluates understanding of relational database modeling, access control principles, and authorization logic, focusing on how users, roles, permissions, and resources relate within a schema.