28
Views
2
Comments
Solved
How to set up the database?

Hi experts,

I would like to set up the database to allow user select the following info:

User can select the project first.

Once user selected the project, if the project got modules under it,  the system will show the module list to ask user select. After that, user can select the Lecture based on the module value.

If the project doesnt have any module, system will pop out the lecture name directly.


Now i designed 3 entities (as following), would like to know if it is possible to combine the 3 entities into 1 and also achieve the above function, or how could i simplify my structure?

  • Lecture Entity (contain LectureID, Lecture Name and Lecture Dept)
  • Project Entity (contain Project ID, Project Name and LectureID)
  • Module Entity (contain ModuleID, Module Name, ProjectID, LectureID)


2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP
Solution

Hi,

It depends on what you want, your example data leaves open a lot of requirements you might have in terms of referential integrity.

If the Project represents a larger unit to study, and a module is a subcomponent of a project, representing a smaller unit to study, and a lecture a specific session within a module, then I would create two relationships:

  • The module has a foreign key to the Project it belongs
  • The lecture has a foreing key to the Module it is part of
  • Project
  • ProjectId
  • ProjectName

Module

  • ModuleId
  • ModuleName
  • ProjectId (foreign key)

Lecture

  • LectureId
  • LectureName
  • LectureDept
  • ModuleId (foreign key)

Not sure why you have a project with a lecture, without a module, I think I would prefer then to create a 'dummy' module on the project like "None"

Regards,

Daniel

2020-11-13 07-48-15
Khuong Truong

Hi @Giselle Chen ,

Base on the requirements, I think DB design should be:

  • Project entity (ProjectId, ProjectName, etc): To store project information.
  • Module entity (ModuleId, ProjectId, ModuleName, etc): To store module information and ProjectId as Foreign Key to link to Project (meaning that modules are under a project)
  • Lecture entity (LectureId, ModuleId, LectureName, etc): To store lecture information and ModuleId as Foreign Key to link to Module (similar to module under project).

It's not good to combine all 3 entities into 1, the reason is that it will make DB store dulicate (redundant) information as not nessessary and may cause loading information slower. If you want to get project information from Lecture you can join to get it by using joining entity via FK. (Lecture join Module and Module join Project)

Regrads,

Khuong

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP
Solution

Hi,

It depends on what you want, your example data leaves open a lot of requirements you might have in terms of referential integrity.

If the Project represents a larger unit to study, and a module is a subcomponent of a project, representing a smaller unit to study, and a lecture a specific session within a module, then I would create two relationships:

  • The module has a foreign key to the Project it belongs
  • The lecture has a foreing key to the Module it is part of
  • Project
  • ProjectId
  • ProjectName

Module

  • ModuleId
  • ModuleName
  • ProjectId (foreign key)

Lecture

  • LectureId
  • LectureName
  • LectureDept
  • ModuleId (foreign key)

Not sure why you have a project with a lecture, without a module, I think I would prefer then to create a 'dummy' module on the project like "None"

Regards,

Daniel

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.