Playing Next Lesson In
seconds

Transcript

  1. Okay, so as promised, here is our database schema for the application that we're working with. There's really two different sections of this. There's a right-hand section and a left-hand section

  2. split down a line, like, kind of right here. So the right-hand portion, we are not really concerned with in terms of adding our API in, because this is all of our roles, users,

  3. how those users map to an organization, and then the user's email history, Remember Me tokens, and password reset tokens. So none of that is stuff that we need to worry about with this API that we're going to be adding.

  4. Everything that we need to worry about here is on the left-hand side over here. So that's our organizations, which pretty much map to everything. So I'm going to go ahead and scroll in here

  5. a little bit further if I can. So our organization is pretty much mapped to everything that's on that left-hand side over here via an organization ID.

  6. From there, we have our access levels, difficulties, and statuses. You can see the columns that are bound to those and what type they are on the right-hand side there. If we continue scrolling on down here,

  7. we can then see our courses, modules, and lessons. And then we also have some tables down here that are bound to anything that we also don't need to worry about.

  8. So let's work our way up covering what maps to what here. So as stated, everything maps to that organization via an organization ID. From there, our lessons map to modules,

  9. our modules then map to courses, and then we have a has-many-through relationship from our courses pointing to our lessons. And that is within our model.

  10. We don't actually see that within the schema here. In terms of those three resources that we have, our access levels, difficulties, and statuses, I briefly mentioned this in the last lesson,

  11. but our access levels map to our courses and our lessons, and that states whether or not that course or lesson is free or paid by default.

  12. Our difficulties map to our courses, and that's just how difficult the overall course is. And then our statuses map to all three, courses, modules, and lessons,

  13. stating what the current status of that item is, whether or not it's not yet started, in progress, done, so on and so forth.

  14. I have a picture of this overall schema added down below this lesson so that you can take a closer look at it if you're on the Adocasts site. If you're on YouTube, then I'll have a link to this

  15. on the Adocasts site there. All right, so we should now be fundamentally familiar with what our web application does. We can then start adding authentication

  16. against our organization in the next module.

Overview of our Database Schema

In This Lesson

We'll take a high level look at our database's schema so that we have an understanding at the entities and models at play and how they relate to one another within our application.

Created by
@tomgobich
Published
PlotMyCourse Database Schema

The Core Tables: Users and Organizations

At the heart of our application are two primary tables: the Users table and the Organizations table. These tables are connected by an intermediary table called Organization Users, which not only links users to organizations but also defines each user's role within the organization. Roles include members and administrators, and these roles dictate what actions a user can perform.

User-Specific Data

We need to store additional user-specific data besides linking users to organizations to ensure a seamless experience. This includes:

  • Password Reset Tokens: For users to reset their passwords.

  • Email History: Keeping track of email changes in case ownership needs to be verified later.

  • Remember Me Tokens: Allowing users to maintain longer sessions without frequent logins.

  • Organization Invites: Handling pending invitations for users to join organizations. Users will need to accept the invite before being added, preventing any involuntary additions.

Organizations and Their Attributes

Each organization in the application has its own set of attributes such as statuses, difficulties, and access levels. These attributes are initialized with default values when a new organization is created but can be customized as needed.

Courses, Modules, and Lessons

Lastly, we'll want tables for courses, modules, and lessons. These entities are linked back to the organization, ensuring that each piece of content has specific access levels and statuses associated with the parent organization.

The Courses table links to Modules, and each Module is further linked to Lessons, creating a hierarchical structure that is easy to navigate and manage.

Join the Discussion 0 comments

Create a free account to join in on the discussion
robot comment bubble

Be the first to comment!