Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
135
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@suin(Craftsman Software)
Organization

SequelProでER図を出力する方法

MySQLのMac用GUI無料クライアントのSequel ProでER図を出す方法です。

こんな感じのER図が出せます。

graphvizを入れとく

brew install graphviz

dotファイルをエクスポートする

Sequel Proで File > Export… > Dot を出力形式で選択 > Export。

dotファイルをpngに変換する

dot -Tpng localhost-db.dot > localhost-db.png

以上。

今回使ったDBのDDL

ちなみに今回出力してみたDBのDDLは次になります。

-- Create syntax for TABLE 'categories'
CREATE TABLE `categories` (
  `id` mediumint(8) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create syntax for TABLE 'items'
CREATE TABLE `items` (
  `id` int(11) unsigned NOT NULL,
  `category_id` mediumint(8) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `category_id` (`category_id`),
  CONSTRAINT `items_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
135
Help us understand the problem. What are the problem?