介绍
本文比较了以下三种自动生成用于数据库设计的ER图的工具。
- dbdiagram.io
- DBeaver
- A5:SQL Mk-2 (A5M2)
前几天,我在奇塔上发了这篇文章,很多人看到了这篇文章,也收到了很多评论。
许多人评论了 ER 图的推荐工具。
这次,我们将尝试免费使用的三个工具的“自动生成ER图”功能。
作为比较的结论,我觉得〇〇不是最好的,但是每个工具都有多种功能,可以做不同的事情,所以我以后使用它们时,我想根据用途使用它们和工作环境。
目录
下面是每个工具的说明。
1. DB dia g 等人。艾欧
1-1. 开始
1-2. 使用
1-3. 印象
2.DBeaver
2-1. 开始
2-2. 使用
2-3. 印象
3. A5:SQL Mk-2(A5M2)
3-1. 开始
3-2. 使用
3-3. 印象
环境
- macOS Big Sur 版本:11.6
- 自制版本:3.5.4
- DBeaver 版本:22.1.4
- A5:SQL Mk-2 (A5M2) 版本:2.17.2
继续上一篇文章,我们将使用 Docker 和 MySQL 创建的数据库作为 Web 应用程序组合作为示例。
1. DB dia g 等人。艾欧
dbdiagram.io 是一个免费且简单的工具,用于输入 DSL 代码和绘制数据库图 (ERD)。 dbdiagram 使用常见的 DBML(数据库标记语言)。
你可以用 dbdiagram.io 做什么是
- 从 SQL 转储文件 (DDL) 快速生成图表(ER 图表)
- 可以直接生成SQL语句(DDL)创建数据库表
等等。
1-1. 开始
访问应用页面并使用 Google 帐户登录后,您可以立即在浏览器上开始使用它。
1-2. 使用
按照以下步骤自动生成 ER 图。
① 创建 SQL 转储文件(DDL)
首先,我使用 Sequel Ace(macOS 的 MySQL/MariaDB 数据库管理工具)准备了一个 SQL 转储文件 (DDL)。 (我现在正在使用另一个工具......)
这是我为导入 dbdiagram.io 而创建的 SQL 转储文件。
用于导入 dbdiagram.io 的 SQL 转储文件
我是按照上面文章中的方法创建的,但是作为准备,注释掉
#会导致SQL出错,所以我删除了所有以#开头的行。此外,
LOCK和UNLOCK已被删除,因为它们在导入 dbdiagram.io 时会导致错误。/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; SET NAMES utf8mb4; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE='NO_AUTO_VALUE_ON_ZERO', SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `child_read_record`; CREATE TABLE `child_read_record` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `read_record_id` bigint unsigned NOT NULL, `child_id` bigint unsigned NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `child_read_record_read_record_id_foreign` (`read_record_id`), KEY `child_read_record_child_id_foreign` (`child_id`), CONSTRAINT `child_read_record_child_id_foreign` FOREIGN KEY (`child_id`) REFERENCES `children` (`id`) ON DELETE CASCADE, CONSTRAINT `child_read_record_read_record_id_foreign` FOREIGN KEY (`read_record_id`) REFERENCES `read_records` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DROP TABLE IF EXISTS `children`; CREATE TABLE `children` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `family_id` bigint unsigned NOT NULL, `name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `gender_code` int DEFAULT NULL, `birthday` date DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `children_family_id_foreign` (`family_id`), CONSTRAINT `children_family_id_foreign` FOREIGN KEY (`family_id`) REFERENCES `families` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- LOCK TABLES `children` WRITE; /*!40000 ALTER TABLE `children` DISABLE KEYS */; INSERT INTO `children` (`id`, `family_id`, `name`, `gender_code`, `birthday`, `created_at`, `updated_at`) VALUES (1,1,'ゆきまさ',1,'2020-04-01','2022-07-15 06:45:00','2022-07-15 06:45:00'), (2,1,'みくり',2,'2021-04-01','2022-07-15 06:45:00','2022-07-15 06:45:00'), (3,2,'お子さま',0,NULL,'2022-07-15 06:50:06','2022-07-15 06:50:06'); /*!40000 ALTER TABLE `children` ENABLE KEYS */; -- UNLOCK TABLES; DROP TABLE IF EXISTS `contacts`; CREATE TABLE `contacts` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `nickname` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `body` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DROP TABLE IF EXISTS `failed_jobs`; CREATE TABLE `failed_jobs` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `connection` text COLLATE utf8mb4_unicode_ci NOT NULL, `queue` text COLLATE utf8mb4_unicode_ci NOT NULL, `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL, `exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL, `failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DROP TABLE IF EXISTS `families`; CREATE TABLE `families` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, `nickname` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `introduction` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `families_name_unique` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- LOCK TABLES `families` WRITE; /*!40000 ALTER TABLE `families` DISABLE KEYS */; INSERT INTO `families` (`id`, `name`, `nickname`, `introduction`, `created_at`, `updated_at`) VALUES (1,'guest','ゲスト','ゲストログインユーザー用です。よろしくお願いします。','2022-07-15 06:45:00','2022-07-15 06:45:00'), (2,'y6E2867HyrBuG9fT','よんで','よろしくお願いします。','2022-07-15 06:50:06','2022-07-15 06:50:06'); /*!40000 ALTER TABLE `families` ENABLE KEYS */; -- UNLOCK TABLES; DROP TABLE IF EXISTS `follows`; CREATE TABLE `follows` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `user_id` bigint unsigned NOT NULL, `family_id` bigint unsigned NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `follows_user_id_foreign` (`user_id`), KEY `follows_family_id_foreign` (`family_id`), CONSTRAINT `follows_family_id_foreign` FOREIGN KEY (`family_id`) REFERENCES `families` (`id`) ON DELETE CASCADE, CONSTRAINT `follows_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DROP TABLE IF EXISTS `invites`; CREATE TABLE `invites` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `family_id` bigint unsigned NOT NULL, `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `token` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `invites_token_unique` (`token`), KEY `invites_family_id_foreign` (`family_id`), CONSTRAINT `invites_family_id_foreign` FOREIGN KEY (`family_id`) REFERENCES `families` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- LOCK TABLES `invites` WRITE; /*!40000 ALTER TABLE `invites` DISABLE KEYS */; INSERT INTO `invites` (`id`, `family_id`, `email`, `token`, `created_at`, `updated_at`) VALUES (1,2,'test2@test','9UyZzBbWeNL41Dcr','2022-07-15 06:51:23','2022-07-15 06:51:23'); /*!40000 ALTER TABLE `invites` ENABLE KEYS */; -- UNLOCK TABLES; DROP TABLE IF EXISTS `likes`; CREATE TABLE `likes` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `user_id` bigint unsigned NOT NULL, `picture_book_id` bigint unsigned NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `likes_user_id_foreign` (`user_id`), KEY `likes_picture_book_id_foreign` (`picture_book_id`), CONSTRAINT `likes_picture_book_id_foreign` FOREIGN KEY (`picture_book_id`) REFERENCES `picture_books` (`id`) ON DELETE CASCADE, CONSTRAINT `likes_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DROP TABLE IF EXISTS `migrations`; CREATE TABLE `migrations` ( `id` int unsigned NOT NULL AUTO_INCREMENT, `migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `batch` int NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- LOCK TABLES `migrations` WRITE; /*!40000 ALTER TABLE `migrations` DISABLE KEYS */; INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (1,'2014_10_12_100000_create_password_resets_table',1), (2,'2019_08_19_000000_create_failed_jobs_table',1), (3,'2021_03_02_171654_create_families_table',1), (4,'2021_03_02_171655_create_users_table',1), (5,'2021_03_02_235959_create_children_table',1), (6,'2021_03_03_000000_create_picture_books_table',1), (7,'2021_03_05_000000_create_read_records_table',1), (8,'2021_03_06_000000_create_child_read_record_table',1), (9,'2021_05_10_155314_create_tags_table',1), (10,'2021_05_10_171704_create_read_record_tag_table',1), (11,'2021_05_11_132606_create_follows_table',1), (12,'2021_05_31_235959_create_likes_table',1), (13,'2021_06_09_180935_create_invites_table',1), (14,'2021_07_09_205018_create_contacts_table',1), (15,'2021_07_18_145514_add_column_soft_deletes_users_table',1); /*!40000 ALTER TABLE `migrations` ENABLE KEYS */; -- UNLOCK TABLES; DROP TABLE IF EXISTS `password_resets`; CREATE TABLE `password_resets` ( `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL, KEY `password_resets_email_index` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DROP TABLE IF EXISTS `picture_books`; CREATE TABLE `picture_books` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `family_id` bigint unsigned NOT NULL, `user_id` bigint unsigned NOT NULL, `google_books_id` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, `isbn_13` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `authors` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `published_date` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `description` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `thumbnail_url` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `five_star_rating` int NOT NULL, `read_status` int NOT NULL, `review` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `picture_books_family_id_foreign` (`family_id`), KEY `picture_books_user_id_foreign` (`user_id`), CONSTRAINT `picture_books_family_id_foreign` FOREIGN KEY (`family_id`) REFERENCES `families` (`id`), CONSTRAINT `picture_books_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DROP TABLE IF EXISTS `read_record_tag`; CREATE TABLE `read_record_tag` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `read_record_id` bigint unsigned NOT NULL, `tag_id` bigint unsigned NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `read_record_tag_read_record_id_foreign` (`read_record_id`), KEY `read_record_tag_tag_id_foreign` (`tag_id`), CONSTRAINT `read_record_tag_read_record_id_foreign` FOREIGN KEY (`read_record_id`) REFERENCES `read_records` (`id`) ON DELETE CASCADE, CONSTRAINT `read_record_tag_tag_id_foreign` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DROP TABLE IF EXISTS `read_records`; CREATE TABLE `read_records` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `picture_book_id` bigint unsigned NOT NULL, `family_id` bigint unsigned NOT NULL, `user_id` bigint unsigned NOT NULL, `memo` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `read_date` date NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `read_records_picture_book_id_foreign` (`picture_book_id`), KEY `read_records_family_id_foreign` (`family_id`), KEY `read_records_user_id_foreign` (`user_id`), CONSTRAINT `read_records_family_id_foreign` FOREIGN KEY (`family_id`) REFERENCES `families` (`id`) ON DELETE CASCADE, CONSTRAINT `read_records_picture_book_id_foreign` FOREIGN KEY (`picture_book_id`) REFERENCES `picture_books` (`id`) ON DELETE CASCADE, CONSTRAINT `read_records_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DROP TABLE IF EXISTS `tags`; CREATE TABLE `tags` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `tags_name_unique` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `family_id` bigint unsigned NOT NULL, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `nickname` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `email_verified_at` timestamp NULL DEFAULT NULL, `password` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `icon_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `relation` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, `deleted_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `users_name_unique` (`name`), UNIQUE KEY `users_email_unique` (`email`,`deleted_at`), KEY `users_family_id_foreign` (`family_id`), CONSTRAINT `users_family_id_foreign` FOREIGN KEY (`family_id`) REFERENCES `families` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- LOCK TABLES `users` WRITE; /*!40000 ALTER TABLE `users` DISABLE KEYS */; INSERT INTO `users` (`id`, `family_id`, `name`, `nickname`, `email`, `email_verified_at`, `password`, `remember_token`, `icon_path`, `relation`, `created_at`, `updated_at`, `deleted_at`) VALUES (1,1,'guest_user','げん(ゲスト)','guest_user@guest.com','2022-07-15 06:45:01',NULL,NULL,'image/1.jpg','パパ','2022-07-15 06:45:01','2022-07-15 06:45:01',NULL), (2,1,'guest_partner','ゆい(パートナー)','guest_partner@guest.com','2022-07-15 06:45:01',NULL,NULL,'image/2.jpg','ママ','2022-07-15 06:45:01','2022-07-15 06:45:01',NULL), (3,2,'kWJ1A7fhlzUZXDAb','やまて','test@test','2022-07-15 06:50:41','$2y$10$JCbzpFTNRTTbYfh9jxp.u.0JB6AETjnJitwofj3tv4Mi7Gn/GyCTm',NULL,NULL,NULL,'2022-07-15 06:50:06','2022-07-15 06:50:41',NULL); /*!40000 ALTER TABLE `users` ENABLE KEYS */; -- UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;② 生成ER图
打开 dbdiagram.io(登录)。
要从 SQL 转储文件生成 ER 图,
按屏幕顶部工具栏上的“导入”→“从 MySQL 导入”。
在下一个屏幕上,上传步骤①中准备的 SQL 转储文件。
上传完成后,自动生成完成,右侧显示ER图,左侧显示作为ER图来源的DBML。
自动生成的 DBML 全文
Table "child_read_record" { "id" bigint [pk, not null, increment] "read_record_id" bigint [not null] "child_id" bigint [not null] "created_at" timestamp [default: NULL] "updated_at" timestamp [default: NULL] Indexes { read_record_id [name: "child_read_record_read_record_id_foreign"] child_id [name: "child_read_record_child_id_foreign"] } } Table "children" { "id" bigint [pk, not null, increment] "family_id" bigint [not null] "name" varchar(100) [default: NULL] "gender_code" int [default: NULL] "birthday" date [default: NULL] "created_at" timestamp [default: NULL] "updated_at" timestamp [default: NULL] Indexes { family_id [name: "children_family_id_foreign"] } } Table "contacts" { "id" bigint [pk, not null, increment] "email" varchar(255) [not null] "nickname" varchar(255) [not null] "name" varchar(255) [default: NULL] "title" varchar(255) [default: NULL] "body" varchar(255) [not null] "created_at" timestamp [default: NULL] "updated_at" timestamp [default: NULL] } Table "failed_jobs" { "id" bigint [pk, not null, increment] "connection" text [not null] "queue" text [not null] "payload" longtext [not null] "exception" longtext [not null] "failed_at" timestamp [not null, default: `CURRENT_TIMESTAMP`] } Table "families" { "id" bigint [pk, not null, increment] "name" varchar(100) [not null] "nickname" varchar(255) [default: NULL] "introduction" varchar(255) [default: NULL] "created_at" timestamp [default: NULL] "updated_at" timestamp [default: NULL] Indexes { name [unique, name: "families_name_unique"] } } Table "follows" { "id" bigint [pk, not null, increment] "user_id" bigint [not null] "family_id" bigint [not null] "created_at" timestamp [default: NULL] "updated_at" timestamp [default: NULL] Indexes { user_id [name: "follows_user_id_foreign"] family_id [name: "follows_family_id_foreign"] } } Table "invites" { "id" bigint [pk, not null, increment] "family_id" bigint [not null] "email" varchar(255) [not null] "token" varchar(16) [not null] "created_at" timestamp [default: NULL] "updated_at" timestamp [default: NULL] Indexes { token [unique, name: "invites_token_unique"] family_id [name: "invites_family_id_foreign"] } } Table "likes" { "id" bigint [pk, not null, increment] "user_id" bigint [not null] "picture_book_id" bigint [not null] "created_at" timestamp [default: NULL] "updated_at" timestamp [default: NULL] Indexes { user_id [name: "likes_user_id_foreign"] picture_book_id [name: "likes_picture_book_id_foreign"] } } Table "migrations" { "id" int [pk, not null, increment] "migration" varchar(255) [not null] "batch" int [not null] } Table "password_resets" { "email" varchar(255) [not null] "token" varchar(255) [not null] "created_at" timestamp [default: NULL] Indexes { email [name: "password_resets_email_index"] } } Table "picture_books" { "id" bigint [pk, not null, increment] "family_id" bigint [not null] "user_id" bigint [not null] "google_books_id" varchar(100) [not null] "isbn_13" varchar(100) [default: NULL] "title" varchar(255) [not null] "authors" varchar(255) [default: NULL] "published_date" varchar(100) [default: NULL] "description" varchar(1000) [default: NULL] "thumbnail_url" varchar(1000) [default: NULL] "five_star_rating" int [not null] "read_status" int [not null] "review" varchar(1000) [default: NULL] "created_at" timestamp [default: NULL] "updated_at" timestamp [default: NULL] Indexes { family_id [name: "picture_books_family_id_foreign"] user_id [name: "picture_books_user_id_foreign"] } } Table "read_record_tag" { "id" bigint [pk, not null, increment] "read_record_id" bigint [not null] "tag_id" bigint [not null] "created_at" timestamp [default: NULL] "updated_at" timestamp [default: NULL] Indexes { read_record_id [name: "read_record_tag_read_record_id_foreign"] tag_id [name: "read_record_tag_tag_id_foreign"] } } Table "read_records" { "id" bigint [pk, not null, increment] "picture_book_id" bigint [not null] "family_id" bigint [not null] "user_id" bigint [not null] "memo" varchar(1000) [default: NULL] "read_date" date [not null] "created_at" timestamp [default: NULL] "updated_at" timestamp [default: NULL] Indexes { picture_book_id [name: "read_records_picture_book_id_foreign"] family_id [name: "read_records_family_id_foreign"] user_id [name: "read_records_user_id_foreign"] } } Table "tags" { "id" bigint [pk, not null, increment] "name" varchar(255) [not null] "created_at" timestamp [default: NULL] "updated_at" timestamp [default: NULL] Indexes { name [unique, name: "tags_name_unique"] } } Table "users" { "id" bigint [pk, not null, increment] "family_id" bigint [not null] "name" varchar(255) [not null] "nickname" varchar(255) [default: NULL] "email" varchar(255) [not null] "email_verified_at" timestamp [default: NULL] "password" varchar(255) [default: NULL] "remember_token" varchar(100) [default: NULL] "icon_path" varchar(255) [default: NULL] "relation" varchar(100) [default: NULL] "created_at" timestamp [default: NULL] "updated_at" timestamp [default: NULL] "deleted_at" timestamp [default: NULL] Indexes { name [unique, name: "users_name_unique"] (email, deleted_at) [unique, name: "users_email_unique"] family_id [name: "users_family_id_foreign"] } } Ref "child_read_record_child_id_foreign":"children"."id" < "child_read_record"."child_id" [delete: cascade] Ref "child_read_record_read_record_id_foreign":"read_records"."id" < "child_read_record"."read_record_id" [delete: cascade] Ref "children_family_id_foreign":"families"."id" < "children"."family_id" Ref "follows_family_id_foreign":"families"."id" < "follows"."family_id" [delete: cascade] Ref "follows_user_id_foreign":"users"."id" < "follows"."user_id" [delete: cascade] Ref "invites_family_id_foreign":"families"."id" < "invites"."family_id" Ref "likes_picture_book_id_foreign":"picture_books"."id" < "likes"."picture_book_id" [delete: cascade] Ref "likes_user_id_foreign":"users"."id" < "likes"."user_id" [delete: cascade] Ref "picture_books_family_id_foreign":"families"."id" < "picture_books"."family_id" Ref "picture_books_user_id_foreign":"users"."id" < "picture_books"."user_id" Ref "read_record_tag_read_record_id_foreign":"read_records"."id" < "read_record_tag"."read_record_id" [delete: cascade] Ref "read_record_tag_tag_id_foreign":"tags"."id" < "read_record_tag"."tag_id" [delete: cascade] Ref "read_records_family_id_foreign":"families"."id" < "read_records"."family_id" [delete: cascade] Ref "read_records_picture_book_id_foreign":"picture_books"."id" < "read_records"."picture_book_id" [delete: cascade] Ref "read_records_user_id_foreign":"users"."id" < "read_records"."user_id" [delete: cascade] Ref "users_family_id_foreign":"families"."id" < "users"."family_id"表的位置好像考虑到了DBML中描述的表的顺序,图片的ER图的表放置手动移动到了我想放置的地方(保存后的状态为移动)。
下面是我尝试导出的 PNG 文件。
1-3. 印象
- 我认为ER图的设计很简单,很酷,很容易阅读。
- 创建图表非常容易,因为您只需要准备一个 SQL 转储文件并将其导出即可。
- 我还发现能够从 ER 图生成 DDL 很有用。
- 使用 DBML(dbdiagram.io 表示法)编写时,理解该表示法需要学习成本,但似乎没有那么困难。
- 由于它不在VSCode扩展中,而且似乎GitHub不支持该符号,我将基本上在dbdiagram.io屏幕上工作。
- 由于团队使用(协作编辑)是收费的,我认为免费版是为了共享导出的文件。
2.DBeaver
DBeaver 是一个数据库管理工具。
有付费版和免费版,甚至免费版都可以自动生成ER图。
它支持各种数据库,而且似乎用途广泛。这次没试过,不过好像也可以从ER图生成DDL。
2-1. 开始
下载 DBeaver。
2-2. 使用
打开 DBeaver 应用程序。如果使用 DBeaver 连接到数据库,可以立即显示 ER 图。
① 添加数据库(MySQL连接)
打开 DBeaver 应用程序并连接到您的数据库。
选择一个数据库并
下载必要的驱动程序和
连接到数据库。
② ER图的显示
您所要做的就是在左侧边栏中选择数据库并打开“ER 图”选项卡。
2-3. 印象
- 我认为ER图的设计非常容易阅读。由于实体(表)和关系(线)的位置是自动生成的,几乎没有重叠,我觉得没有必要手动调整。
- 我觉得很容易阅读,因为主键显示在右侧,外键显示在左侧。
- 这次想尝试的是自动生成ER图,但是作为一个数据库管理工具,它支持各种数据库,功能也很多,所以我觉得如果能掌握的话会很方便。
3. A5:SQL Mk-2(A5M2)
A5:SQL Mk-2 是一款免费的 SQL 客户端,旨在支持复杂的数据库开发。
它的开发目标是功能强大、重量轻且易于使用。
除了执行 SQL 和编辑表之外,您还可以获取 SQL 执行计划和创建 ER 图。
3-1. 开始
因为它有点长A5M2(A5:SQL Mk-2) 在 macOS 上的总结在这篇文章中。
3-2. 使用
按照以下步骤自动生成 ER 图。
① 添加数据库(MySQL连接)
启动 A5M2。
按“注册表”并继续连接数据库。
让我们连接到 Web 应用程序(组合)的数据库。
② 生成ER图
从数据库中创建的表生成 ER 图。
按工具栏“数据库”→“ER图”→“ER图的反向生成”。
选择表格
按“生成反向 ER 图”。
这个ER图是手动改变的实体(表)的位置关系。
3-3. 印象
- A5M2的GUI和ER图设计比较简单,但是可以自动从表生成ER图,也可以生成DDL从ER图创建表,非常方便。
- 自开发开始以来似乎已经过去了 25 年(哇...),但它似乎仍在维护中,并且仍然很活跃。
- 在Qiita的文章和Hatena书签的评论中,我想推荐A5M2的人很多,我很服气。
概括
这次尝试了三个工具的“自动生成ER图”的功能,但是每个工具都有不同的功能,所以以后想了解一下功能,根据用途使用。我在想。
非常感谢。
原创声明:本文系作者授权爱码网发表,未经许可,不得转载;
原文地址:https://www.likecs.com/show-308623420.html