Skip to content
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

Update database diagram using MySQL Workshop #22

Merged
merged 1 commit into from
Oct 9, 2020
Merged

Conversation

eloquence
Copy link
Member

@eloquence eloquence commented Oct 7, 2020

Status

Ready for review

Description of Changes

Brings the database diagram up to date and includes cardinalities in crow's foot notation.

This diagram was created using MySQL Workshop, which is open source and cross-platform (while designed for MySQL, there does not appear to be a conflict between its capabilities and our relatively modest requirements). To create it, I first dumped the SQLite database and imported it using the "Import > Reverse Engineer MySQL Create Script" option. The main things I manually adjusted after that are:

  • using the "indexes" section to enumerate UNIQUE constraints and foreign keys (seemed like the best fit).
  • correcting the source<->star relationship to be 1:1 (side note: why this is a separate table is unclear to me)
  • changing TINYINT to BOOLEAN for readability (both MySQL and SQLite store Booleans as {0,1} integers internally)

Resolves #7.

Alternatives considered

I evaluated SQLeton and ERAlchemy for fully automatic diagram generation. Neither choice offered sufficient flexibility to allow for correcting cardinalities, choosing notation styles, optimizing placement, or configuring the display of column flags such as NOT NULL or UNIQUE.

MySQL Workbench seemed a good middle ground between partial automation and partial manual effort.

SQLeton generated diagram

SQLeton

ERAlchemy generated diagram

ERAlchemy

Review

  1. Spin up the SecureDrop Docker development environment via make dev in your SecureDrop checkout directory
  2. Shell into it via docker exec -it securedrop-dev-0 bash
  3. Run SQLite via sqlite3 /var/lib/securedrop/db.sqlite
  4. Output the schema via .schema

Compare the output with the diagram securedrop-database.png from this PR:

  1. Are the table descriptions accurate?
  2. Are the relationships (including cardinalities) accurate?

Checklist (Optional)

  • Doc linting (make docs-lint) passed locally
  • You have previewed (make docs) docs at http://localhost:8000

@@ -131,7 +131,9 @@ Note that the ``cat`` example above will also add the ATHS info for the
Architecture Diagrams
---------------------
Copy link
Member Author

Choose a reason for hiding this comment

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

As a side note, this section is extremely buried in our docs right now, suggestions for reorganizing welcome for a follow-up PR :)


.. image:: ../diagrams/securedrop-database.png
:width: 100%
Copy link
Member Author

Choose a reason for hiding this comment

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

This ensures that clicking the diagram will display the full-size version.

@sssoleileraaa
Copy link
Contributor

Seems like Primary isn't showing what the primary key is, right?

primary-key

@sssoleileraaa
Copy link
Contributor

Oh, I see, the little yellow light bulb is the indicator. Just weird to see "PRIMARY" by itself there.

@eloquence
Copy link
Member Author

I think it's supposed to be a key icon. Yeah, mysql-workbench doesn't let you name that in the "indexes" section, presumably because "there can be only one" (cue Highlander theme).

@sssoleileraaa
Copy link
Contributor

correcting the source<->star relationship to be 1:1 (side note: why this is a separate table is unclear to me)

@sssoleileraaa
Copy link
Contributor

sssoleileraaa commented Oct 9, 2020

^ oops i keep pressing Ctrl+Enter because SecureDrop client is training me to!!

correcting the source<->star relationship to be 1:1 (side note: why this is a separate table is unclear to me)

I don't think it normalizes anything and could be moved into the sources table

Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

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

lgtm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update database diagram
2 participants