简体   繁体   中英

Database design for a tutorial web application

We have a requirement of creating a tutorial kind of application, where there will be list of topics and each topics would have sub topics. The user can enroll for a topic, and go through the sub topics and mark the sub topics as "Completed". We are opting to use MySql relational DB.

So. there are typically 3 master tables,

  1. users
  2. topics
  3. sub_topics

We are planning to continue with the approach by making mapping tables for ' users and topics ' ie ' user_topics ' where it contains column as user_id , topic_id , is_enrolled And another mapping table to track the completion status of the sub topics, may be ' user_sub_topics ' where it contains user_id , sub_topic_id , topic_id , is_completed

Is it the best way to design DB? or any other work around can be done?

Here are the few queries we need to get the data

  1. Topic list will display list of topics with completed label if user has completed all the sub topics (Join query would help)
  2. Topic detail page would display list of completed sub topics too

Please suggest

first you have to design such relational database by finding the relations between entities and to do so study a bit about ER or extended ER diagram(Entity Relation) and then convert your diagram into tables.

there is a step by step method which shows how to do so and at the end you can check for normal form of your tables and check whether it satisfies your purpose and how good is your design.

I strongly suggest you Fundamentals of Database Systems by Ramez Elmasri it will provide great information about database design

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM