
#Dbvisualizer er diagram driver#
Now, select “SQLite” from the driver dropdown menu and click “Next.” Then, navigate to “Database file name” in the “Database” section of the proceeding window. Click the down arrow button to the right of mysqlite.db (if this button does not appear double-click the text box containing mysqlite.db), find the student_records.db file on your machine, and select the file. There are a few additional points worth discussing. First, notice the key icons to the left of various attribute names. These icons identify the primary keys in the tables. In a relational database the attribute, or set of attributes, used to uniquely identify records is called the primary key. A related concept is that of the foreign key, which is an attribute in one table that is a primary key in another table. As such, the primary and foreign keys form a blueprint for joins. Second, note that the student_courses table has two key icons because the primary key in that table is a composite of student_id and course_id. Neither student_id nor course_id are sufficient for identifying unique records in this table.


Rather, the combination of student_id and course_id uniquely identifies each record in the table. Third, when a table containing foreign keys is selected (e.g., student_courses), the outbound links to the related tables will be in green. Conversely, when a table referenced by other tables’ foreign keys is selected, the inbound links will be colored in red.

Bidirectional links, if present, will appear in orange.įourth, the ERD generation feature in Dbvisualizer only works if primary and foreign keys are identified when creating tables.
#Dbvisualizer er diagram code#
CREATE TABLE student_coursesįOREIGN KEY(student_id) REFERENCES students(student_id)įOREIGN KEY(course_id) REFERENCES courses(course_id)įOREIGN KEY(grade) REFERENCES grades(grade) Consider the SQL code below used to create the student_records database. In this code, the primary and foreign keys are established at the end of each code block creating each individual table. Unfortunately, if your tables were not created with the primary and foreign keys identified then you will be unable to generate the ERD. Why So Many Tables?Īt this point, if you are like me when I was learning SQL you may be asking, “why do we even need to have data spread across multiple tables in the first place?” The answer is normalization, a data storage practice that helps to ensure data integrity by preventing data redundancies and protecting against various anomalies when altering tables. Normalization is enforced through normal forms, of which the first three are particularly important. To illustrate the normalization process say that our example database was initially stored as the single table shown below.
