Skip to content

added dbml file and updated dbml-schema #1123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
324 changes: 324 additions & 0 deletions db/dbschema.dbml
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
table LogEntry {
action_time datetime [note: "primary_key : False<br>nullable : False<br>blank : False"]
user foreign_key
content_type foreign_key
object_id text [note: "primary_key : False<br>nullable : True<br>blank : True"]
object_repr varchar [note: "primary_key : False<br>max_length : 200<br>nullable : False<br>blank : False"]
action_flag positive_small_int [note: "primary_key : False<br>nullable : False<br>blank : False<br>choices : [(1, 'Addition'), (2, 'Change'), (3, 'Deletion')]"]
change_message text [note: "primary_key : False<br>nullable : False<br>blank : True"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Permission {
name varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : False"]
content_type foreign_key
codename varchar [note: "primary_key : False<br>max_length : 100<br>nullable : False<br>blank : False"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Group {
name varchar [note: "primary_key : False<br>max_length : 150<br>nullable : False<br>blank : False"]
permissions many_to_many
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table ContentType {
app_label varchar [note: "primary_key : False<br>max_length : 100<br>nullable : False<br>blank : False"]
model varchar [note: "primary_key : False<br>max_length : 100<br>nullable : False<br>blank : False"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Session {
session_key varchar [note: "primary_key : True<br>max_length : 40<br>nullable : False<br>blank : False"]
session_data text [note: "primary_key : False<br>nullable : False<br>blank : False"]
expire_date datetime [note: "primary_key : False<br>nullable : False<br>blank : False"]
}

table School {
name varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : False"]
description text [note: "primary_key : False<br>nullable : False<br>blank : True"]
website url [note: "primary_key : False<br>max_length : 200<br>nullable : False<br>blank : True"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Department {
name varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : False"]
description text [note: "primary_key : False<br>nullable : False<br>blank : True"]
website url [note: "primary_key : False<br>max_length : 200<br>nullable : False<br>blank : True"]
school foreign_key
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Subdepartment {
name varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : False"]
description text [note: "primary_key : False<br>nullable : False<br>blank : True"]
mnemonic varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : False"]
department foreign_key
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table ClubCategory {
name varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : False"]
description text [note: "primary_key : False<br>nullable : False<br>blank : True"]
slug slug [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : False"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Club {
name varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : False"]
description text [note: "primary_key : False<br>nullable : False<br>blank : True"]
category foreign_key
combined_name varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : True"]
application_required boolean [note: "primary_key : False<br>nullable : False<br>blank : False"]
photo_url varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : True"]
meeting_time varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : True"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table User {
computing_id varchar [note: "primary_key : False<br>max_length : 20<br>nullable : False<br>blank : True"]
graduation_year int [note: "primary_key : False<br>nullable : True<br>blank : True"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add validation constraints for graduation_year

The graduation_year field lacks validation constraints. Consider adding minimum and maximum year boundaries to prevent invalid data entry.

Add constraints in your Django model:

graduation_year = models.IntegerField(
    validators=[MinValueValidator(1900), MaxValueValidator(2100)],
    null=True, blank=True
)
🤖 Prompt for AI Agents
In db/dbschema.dbml at line 80, the graduation_year field lacks validation
constraints to ensure valid year values. Add minimum and maximum year boundaries
by updating the Django model to include validators MinValueValidator(1900) and
MaxValueValidator(2100) on the graduation_year IntegerField, while keeping null
and blank as True.

password varchar [note: "primary_key : False<br>max_length : 128<br>nullable : False<br>blank : False"]
last_login datetime [note: "primary_key : False<br>nullable : True<br>blank : True"]
is_superuser boolean [note: "primary_key : False<br>nullable : False<br>blank : False"]
username varchar [note: "primary_key : False<br>max_length : 150<br>nullable : False<br>blank : False"]
first_name varchar [note: "primary_key : False<br>max_length : 150<br>nullable : False<br>blank : True"]
last_name varchar [note: "primary_key : False<br>max_length : 150<br>nullable : False<br>blank : True"]
email email [note: "primary_key : False<br>max_length : 254<br>nullable : False<br>blank : True"]
is_staff boolean [note: "primary_key : False<br>nullable : False<br>blank : False"]
is_active boolean [note: "primary_key : False<br>nullable : False<br>blank : False"]
date_joined datetime [note: "primary_key : False<br>nullable : False<br>blank : False"]
groups many_to_many
user_permissions many_to_many
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Instructor {
first_name varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : True"]
last_name varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : False"]
full_name varchar [note: "primary_key : False<br>max_length : 511<br>nullable : False<br>blank : True"]
email email [note: "primary_key : False<br>max_length : 254<br>nullable : False<br>blank : True"]
departments many_to_many
hidden boolean [note: "primary_key : False<br>nullable : False<br>blank : False"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Semester {
year int [note: "primary_key : False<br>nullable : False<br>blank : False"]
season varchar [note: "primary_key : False<br>max_length : 7<br>nullable : False<br>blank : False<br>choices : (('FALL', 'Fall'), ('JANUARY', 'January'), ('SPRING', 'Spring'), ('SUMMER', 'Summer'))"]
number int [note: "primary_key : False<br>nullable : False<br>blank : False"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Discipline {
name varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : False"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Course {
title varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : False"]
description text [note: "primary_key : False<br>nullable : False<br>blank : True"]
disciplines many_to_many
number int [note: "primary_key : False<br>nullable : False<br>blank : False"]
subdepartment foreign_key
semester_last_taught foreign_key
combined_mnemonic_number varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : True"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table CourseEnrollment {
course one_to_one
last_update datetime [note: "primary_key : False<br>nullable : False<br>blank : True"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table CourseGrade {
course foreign_key
average float [note: "primary_key : False<br>nullable : True<br>blank : False"]
a_plus int [note: "primary_key : False<br>nullable : False<br>blank : False"]
a int [note: "primary_key : False<br>nullable : False<br>blank : False"]
a_minus int [note: "primary_key : False<br>nullable : False<br>blank : False"]
b_plus int [note: "primary_key : False<br>nullable : False<br>blank : False"]
b int [note: "primary_key : False<br>nullable : False<br>blank : False"]
b_minus int [note: "primary_key : False<br>nullable : False<br>blank : False"]
c_plus int [note: "primary_key : False<br>nullable : False<br>blank : False"]
c int [note: "primary_key : False<br>nullable : False<br>blank : False"]
c_minus int [note: "primary_key : False<br>nullable : False<br>blank : False"]
dfw int [note: "primary_key : False<br>nullable : False<br>blank : False"]
total_enrolled int [note: "primary_key : False<br>nullable : False<br>blank : False"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table CourseInstructorGrade {
instructor foreign_key
course foreign_key
average float [note: "primary_key : False<br>nullable : True<br>blank : False"]
a_plus int [note: "primary_key : False<br>nullable : False<br>blank : False"]
a int [note: "primary_key : False<br>nullable : False<br>blank : False"]
a_minus int [note: "primary_key : False<br>nullable : False<br>blank : False"]
b_plus int [note: "primary_key : False<br>nullable : False<br>blank : False"]
b int [note: "primary_key : False<br>nullable : False<br>blank : False"]
b_minus int [note: "primary_key : False<br>nullable : False<br>blank : False"]
c_plus int [note: "primary_key : False<br>nullable : False<br>blank : False"]
c int [note: "primary_key : False<br>nullable : False<br>blank : False"]
c_minus int [note: "primary_key : False<br>nullable : False<br>blank : False"]
dfw int [note: "primary_key : False<br>nullable : False<br>blank : False"]
total_enrolled int [note: "primary_key : False<br>nullable : False<br>blank : False"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Section {
sis_section_number int [note: "primary_key : False<br>nullable : False<br>blank : False"]
instructors many_to_many
semester foreign_key
course foreign_key
topic text [note: "primary_key : False<br>nullable : False<br>blank : True"]
cost varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : True"]
units varchar [note: "primary_key : False<br>max_length : 10<br>nullable : False<br>blank : True"]
section_type varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : True"]
section_times varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : True"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table SectionTime {
section foreign_key
monday boolean [note: "primary_key : False<br>nullable : False<br>blank : False"]
tuesday boolean [note: "primary_key : False<br>nullable : False<br>blank : False"]
wednesday boolean [note: "primary_key : False<br>nullable : False<br>blank : False"]
thursday boolean [note: "primary_key : False<br>nullable : False<br>blank : False"]
friday boolean [note: "primary_key : False<br>nullable : False<br>blank : False"]
start_time time [note: "primary_key : False<br>nullable : False<br>blank : False"]
end_time time [note: "primary_key : False<br>nullable : False<br>blank : False"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table SectionEnrollment {
section foreign_key
enrollment_taken int [note: "primary_key : False<br>nullable : True<br>blank : True"]
enrollment_limit int [note: "primary_key : False<br>nullable : True<br>blank : True"]
waitlist_taken int [note: "primary_key : False<br>nullable : True<br>blank : True"]
waitlist_limit int [note: "primary_key : False<br>nullable : True<br>blank : True"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Review {
text text [note: "primary_key : False<br>nullable : False<br>blank : True"]
user foreign_key
course foreign_key
club foreign_key
instructor foreign_key
Comment on lines +207 to +209
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider separating course and club reviews

The Review table has foreign keys to both course and club, suggesting it serves dual purposes. This violates the single responsibility principle and could complicate queries and business logic.

Consider splitting into separate tables:

  • CourseReview for course-related reviews
  • ClubReview for club-related reviews

This would improve maintainability and allow for type-specific fields and validations.

🤖 Prompt for AI Agents
In db/dbschema.dbml around lines 207 to 209, the Review table currently has
foreign keys to both course and club, mixing two distinct review types. To fix
this, split the Review table into two separate tables: CourseReview with a
foreign key to course, and ClubReview with a foreign key to club. This
separation will clarify responsibilities, simplify queries, and allow for
specific fields and validations per review type.

semester foreign_key
email varchar [note: "primary_key : False<br>nullable : True<br>blank : True"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Security concern: Redundant email storage

The email field appears redundant since reviews are already linked to users who have email addresses. Storing emails in multiple places increases PII exposure risk.

Remove the email field and retrieve it through the user relationship when needed:

-email varchar [note: "primary_key : False<br>nullable : True<br>blank : True"]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
email varchar [note: "primary_key : False<br>nullable : True<br>blank : True"]
🤖 Prompt for AI Agents
In db/dbschema.dbml at line 211, the email field is redundant because user
emails can be accessed via the user relationship in reviews. Remove the email
field from this table to reduce PII exposure and ensure any email data is
retrieved through the associated user entity instead.

toxicity_rating int [note: "primary_key : False<br>nullable : False<br>blank : False"]
toxicity_category varchar [note: "primary_key : False<br>nullable : False<br>blank : True"]
instructor_rating positive_small_int [note: "primary_key : False<br>nullable : False<br>blank : False<br>choices : ((1, 1), (2, 2), (3, 3), (4, 4), (5, 5))"]
difficulty positive_small_int [note: "primary_key : False<br>nullable : False<br>blank : False<br>choices : ((1, 1), (2, 2), (3, 3), (4, 4), (5, 5))"]
recommendability positive_small_int [note: "primary_key : False<br>nullable : False<br>blank : False<br>choices : ((1, 1), (2, 2), (3, 3), (4, 4), (5, 5))"]
enjoyability positive_small_int [note: "primary_key : False<br>nullable : False<br>blank : False<br>choices : ((1, 1), (2, 2), (3, 3), (4, 4), (5, 5))"]
hours_per_week positive_small_int [note: "primary_key : False<br>nullable : False<br>blank : False"]
amount_reading positive_small_int [note: "primary_key : False<br>nullable : False<br>blank : False"]
amount_writing positive_small_int [note: "primary_key : False<br>nullable : False<br>blank : False"]
amount_group positive_small_int [note: "primary_key : False<br>nullable : False<br>blank : False"]
amount_homework positive_small_int [note: "primary_key : False<br>nullable : False<br>blank : False"]
created datetime [note: "primary_key : False<br>nullable : False<br>blank : True"]
modified datetime [note: "primary_key : False<br>nullable : False<br>blank : True"]
hidden boolean [note: "primary_key : False<br>nullable : False<br>blank : False"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Vote {
value int [note: "primary_key : False<br>nullable : False<br>blank : False"]
user foreign_key
review foreign_key
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Question {
text text [note: "primary_key : False<br>nullable : False<br>blank : False"]
course foreign_key
instructor foreign_key
user foreign_key
created datetime [note: "primary_key : False<br>nullable : False<br>blank : True"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Answer {
text text [note: "primary_key : False<br>nullable : False<br>blank : False"]
question foreign_key
user foreign_key
created datetime [note: "primary_key : False<br>nullable : False<br>blank : True"]
semester foreign_key
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table VoteQuestion {
value int [note: "primary_key : False<br>nullable : False<br>blank : False"]
user foreign_key
question foreign_key
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table VoteAnswer {
value int [note: "primary_key : False<br>nullable : False<br>blank : False"]
user foreign_key
answer foreign_key
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table Schedule {
name varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : False"]
user foreign_key
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

table ScheduledCourse {
schedule foreign_key
section foreign_key
instructor foreign_key
time varchar [note: "primary_key : False<br>max_length : 255<br>nullable : False<br>blank : False"]
id int [note: "primary_key : True<br>nullable : False<br>blank : True"]
}

ref: LogEntry.user > User.id
ref: LogEntry.content_type > ContentType.id
ref: Permission.content_type > ContentType.id
ref: Group.permissions > Permission.name
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Critical: Foreign key references should use primary keys

Foreign key references are incorrectly pointing to non-primary key fields (e.g., name, first_name) instead of id fields. This violates referential integrity best practices and can cause performance and data consistency issues.

Apply these corrections to use primary keys:

-ref: Group.permissions > Permission.name
+ref: Group.permissions > Permission.id
-ref: User.groups > Group.name
+ref: User.groups > Group.id
-ref: User.user_permissions > Permission.name
+ref: User.user_permissions > Permission.id
-ref: Instructor.departments > Department.name
+ref: Instructor.departments > Department.id
-ref: Course.disciplines > Discipline.name
+ref: Course.disciplines > Discipline.id
-ref: Section.instructors > Instructor.first_name
+ref: Section.instructors > Instructor.id

Also applies to: 289-293, 299-299

🤖 Prompt for AI Agents
In db/dbschema.dbml at line 285 and also lines 289-293 and 299, foreign key
references currently point to non-primary key fields like 'name' or
'first_name'. Update these foreign key references to point to the corresponding
primary key fields, typically 'id', to ensure proper referential integrity and
data consistency.

ref: Department.school > School.id
ref: Subdepartment.department > Department.id
ref: Club.category > ClubCategory.id
ref: User.groups > Group.name
ref: User.user_permissions > Permission.name
ref: Instructor.departments > Department.name
ref: Course.disciplines > Discipline.name
ref: Course.subdepartment > Subdepartment.id
ref: Course.semester_last_taught > Semester.id
ref: CourseEnrollment.course > Course.id
ref: CourseGrade.course > Course.id
ref: CourseInstructorGrade.instructor > Instructor.id
ref: CourseInstructorGrade.course > Course.id
ref: Section.instructors > Instructor.first_name
ref: Section.semester > Semester.id
ref: Section.course > Course.id
ref: SectionTime.section > Section.id
ref: SectionEnrollment.section > Section.id
ref: Review.user > User.id
ref: Review.course > Course.id
ref: Review.club > Club.id
ref: Review.instructor > Instructor.id
ref: Review.semester > Semester.id
ref: Vote.user > User.id
ref: Vote.review > Review.id
ref: Question.course > Course.id
ref: Question.instructor > Instructor.id
ref: Question.user > User.id
ref: Answer.question > Question.id
ref: Answer.user > User.id
ref: Answer.semester > Semester.id
ref: VoteQuestion.user > User.id
ref: VoteQuestion.question > Question.id
ref: VoteAnswer.user > User.id
ref: VoteAnswer.answer > Answer.id
ref: Schedule.user > User.id
ref: ScheduledCourse.schedule > Schedule.id
ref: ScheduledCourse.section > Section.id
ref: ScheduledCourse.instructor > Instructor.id
Binary file added db/dbschema.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading