![]() This is necessary so that the grading system can have the following properties: Many-to-many relations typically require an additional table. User Course (via the CourseEnrollment relation table with two foreign keys: userId and courseId).The first thing to note about the diagram is that every entity maps to a database table. The diagram below adds the columns relevant for each entity and foreign keys to describe the relationships between the entities. The entities can be visualized to demonstrate how they would be represented in a relational database (in this case PostgreSQL). For example, a user represents a person, whereas a course is an intangible concept. Note: An entity represents either a physical object or an intangible concept. Additionally, a TestResult is also related to the teacher who graded the test. Test result: Each test can have multiple test result records per student.Tests have a date and are related to a course. Test: A course can have many tests to evaluate the students' comprehension.For example: an "Introduction to TypeScript" course can have two teachers and ten students. Course: A learning course with one or more teachers and students as well as one or more tests.In other words, the same user who's a teacher of one course can be a student in another course. A user can be either a teacher or a student through their relation to a course. The online grading system will have the following entities: The problem domain (or problem space) is a term referring to all information that defines the problem and constrains the solution (the constraints being part of the problem).īy understanding the problem domain, the shape and structure of the data model should become clear. When building a backend, one of the foremost concerns is a proper understanding of the problem domain. Data model for a grading system for online courses Defining the problem domain and entities Note: Docker will use the docker-compose.yml file to start the PostgreSQL container. To get started, clone the repository and install the dependencies: The source code for the series can be found on GitHub. Note: If you don't want to use Docker, you can set up a local PostgreSQL database or a hosted PostgreSQL database on Heroku. If you're using Visual Studio Code, the Prisma extension is recommended for syntax highlighting, formatting, and other helpers. Docker (will be used to run a development PostgreSQL database).Beyond that, no prior knowledge of Prisma is required as that will be covered in the series. The series will use PostgreSQL, however, most of the concepts apply to other relational databases such as MySQL. If you're experienced with JavaScript but haven't had the chance to try TypeScript, you should still be able to follow along. This series assumes basic knowledge of TypeScript, Node.js, and relational databases. Note: Throughout the guide you'll find various checkpoints that enable you to validate whether you performed the steps correctly. The next parts of this series will cover the other aspects from the list in detail. Aggregation: Implement aggregate queries with Prisma to calculate averages, etc.īy the end of this article you will have a Prisma schema, a corresponding database schema created by Prisma Migrate, and a seed script which uses Prisma Client to perform CRUD and aggregation queries.CRUD: Implement Create, Read, Update, and Delete queries with Prisma Client against the database.Data modeling: Mapping the problem domain to a database schema.This first article of the series will begin by laying out the problem domain and developing the following aspects of the backend: The series will focus on the role of the database in every aspect of backend development covering: The recording of the live stream is available above and covers the same ground as this article. This is a good example because it features diverse relations types and is complex enough to represent a real-world use-case. ![]() The goal of the series is to explore and demonstrate different patterns, problems, and architectures for a modern backend by solving a concrete problem: a grading system for online courses.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |