db-schema-visualizer icon indicating copy to clipboard operation
db-schema-visualizer copied to clipboard

Composite PK Support

Open ptyork opened this issue 5 months ago • 2 comments

DBDiagram.io supports both a documented and an undocumented way of specifying composite primary keys.

Documented:

Table CourseSection {
    Year char(4)
    SemesterCode char(2)
    SectionCode char(2)
    CoursePrefix char(4) [ref: > Course.CoursePrefix]
    CourseNumber char(4) [ref: > Course.CourseNumber]
    InstructorID char(9) [ref: > Faculty.EmployeeID]
    RoomCode char(10) [ref: > Room.RoomCode]
    Indexes {
        (Year,SemesterCode,SectionCode,CoursePrefix,CourseNumber) [pk]
    }
}

Undocumented:

Table CourseSection {
    Year char(4) [pk]
    SemesterCode char(2) [pk]
    SectionCode char(2) [pk]
    CoursePrefix char(4) [pk, ref: > Course.CoursePrefix]
    CourseNumber char(4) [pk, ref: > Course.CourseNumber]
    InstructorID char(9) [ref: > Faculty.EmployeeID]
    RoomCode char(10) [ref: > Room.RoomCode]
}

Supporting the documented way would be a high-priority request given how common this scenario is...though obviously a 5-part key is an abomination that I'm using as an anti-pattern in a lecture. The undocumented way is quite nice for beginners.

Thanks!

PS - if you have no time but can process PR's, I will take a stab at my outstanding feature and bug reports.

ptyork avatar Sep 08 '24 19:09 ptyork