Skip to content

Commit 3882549

Browse files
committed
Updated README
1 parent d0a0b19 commit 3882549

File tree

2 files changed

+32
-21
lines changed

2 files changed

+32
-21
lines changed

README.md

+32-21
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,29 @@
66

77
A relational database schema visualizer built with React and [ReactFlow](https://github.com/wbkd/react-flow).
88

9-
Originally built for [the SQL Habit course](https://www.sqlhabit.com/), it's now available for everyone. Enjoy :heart:
9+
Originally built for [the SQL Habit course](https://www.sqlhabit.com/), it's available for everyone. Enjoy :heart:
1010

1111
[:mag: How to visualize your schema](https://github.com/sqlhabit/sql_schema_visualizer#how-to-visualize-your-schema) | [:microscope: How it works](https://github.com/sqlhabit/sql_schema_visualizer#under-the-hood) | [:handshake: Contributing](https://github.com/sqlhabit/sql_schema_visualizer#contributing)
1212

1313
</div>
1414

1515
## Features
1616

17-
:dash: **Easy to start**: you can import your schema in 1.5 minutes.
17+
:dash: **Easy to start**: you can import your schema(s) in 1.5 minutes.
1818
<br>
1919
:checkered_flag: **Easy to finish**: you only need to configure edges and table positions.
2020
<br>
2121
:wrench: **Customizable**: add table/column descriptions and schema colors.
2222
<br>
2323
:rocket: **Make it yours**: you get the whole React app, so you can change everything.
2424

25-
## How to visualize your schema
25+
## How to visualize your schema(s)
26+
27+
Schema Visualizer can visualize multiple schemas – each schema will have its own URL.
28+
29+
A schema configuration lives in its own folder and contains a bunch of simple JSON files.
30+
31+
Here's how you can import your schema:
2632

2733
### Step 1. Clone and set up the repo
2834

@@ -34,31 +40,27 @@ git clone https://github.com/sqlhabit/sql_schema_visualizer.git
3440
cd sql_schema_visualizer
3541
```
3642

37-
Schema Visualizer is a React app. Here's how to install dependencies:
43+
Install dependencies:
3844

3945
```bash
4046
npm run install
41-
42-
npm run start
4347
```
4448

45-
:computer: Now Schema Visualizer is running on your 9292 port: [http://localhost:9292](http://localhost:9292).
46-
4749
:bulb: You might need to install [nvm](https://github.com/nvm-sh/nvm#installing-and-updating) as well to make sure you're not using an old Node version.
4850

4951
### Step 2. Reset schema configuration
5052

51-
At this point, you should see the default schema in your browser. Let's reset all schema config files:
53+
By default, Schema Visualizer contains [SQL Habit's](https://www.sqlhabit.com) dataset schemas. Let's delete all of them first:
5254

5355
```bash
5456
npm run reset
5557
```
5658

57-
After running this command, you should see an empty grid in your browser.
58-
5959
### Step 3. Export your schema into a CSV file
6060

61-
Pick a query that works for your database. Save the output of this query to the `schema.csv` file in the root folder (next to [the `schema.csv.template` file](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/schema.csv.template)).
61+
A schema config consists of tables and edges. We can import table structures with an SQL query.
62+
63+
Pick a query that works for your database and save the output to a CSV file like `my_schema.csv`. Put it to the root folder (next to [the `schema.csv.template` file](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/schema.csv.template)).
6264

6365
#### Postgres / Redshift
6466

@@ -99,17 +101,26 @@ WHERE
99101

100102
### Step 4. Import schema
101103

104+
Now we can import tables. The argument of the `npm run import` is your CSV file name:
105+
106+
102107
```bash
103-
npm run import
108+
npm run import my_schema
104109
```
105110

106-
Now you should see tables from your schema scattered in your browser.
111+
You should see table JSON files added to the `src/config/my_schema/tables` folder.
112+
113+
Let's spin up a dev server and see our tables in the browser (they should be available on the [http://localhost:9292/](http://localhost:9292/)):
114+
115+
```bash
116+
npm run start
117+
```
107118

108119
### Step 5. Configure your schema
109120

110121
#### A. Set primary keys
111122

112-
To show a :key: icon next to the column name, add the `key` param to a column definition. Here's an example from [the `users` table](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/src/config/tables/users.json):
123+
To show a :key: icon next to the column name, add the `key` param to a column definition. Here's an example from [the `users` table](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/src/config/databases/bindle/tables/users.json):
113124

114125
```json
115126
{
@@ -122,7 +133,7 @@ To show a :key: icon next to the column name, add the `key` param to a column de
122133

123134
#### B. Add edges
124135

125-
Define edges in [the `src/config/edges.json` file](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/src/config/edges.json):
136+
Define edges in [the `src/config/edges.json` file](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/src/config/databases/bindle/edges.json):
126137

127138
Here's an example for **has one** relation:
128139

@@ -150,7 +161,7 @@ and **has many** relation:
150161

151162
#### C. Add schema colors
152163

153-
You can set custom header colors for tables that belongs to the same schema in [the `src/config/schemaColors.json` file](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/src/config/schemaColors.json). Here's an example:
164+
You can set custom header colors for tables that belongs to the same schema in [the `schemaColors.json` file](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/src/config/databases/bindle/schemaColors.json). Here's an example:
154165

155166
```json
156167
{
@@ -165,7 +176,7 @@ You can set custom header colors for tables that belongs to the same schema in [
165176

166177
#### D. Add table positions
167178

168-
Table positions are defined in the [`src/config/tablePositions.json` file](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/src/config/tablePositions.json):
179+
Table positions are defined in the [`tablePositions.json` file](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/src/config/databases/bindle/tablePositions.json):
169180

170181
```json
171182
{
@@ -183,21 +194,21 @@ Table positions are defined in the [`src/config/tablePositions.json` file](https
183194
}
184195
```
185196

186-
After you import a schema, every table will have a default position set in the [`src/config/tablePositions.json`](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/src/config/tablePositions.json) file.
197+
After you import a schema, every table will have a default position set in the [`tablePositions.json`](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/src/config/databases/bindle/tablePositions.json) file.
187198

188199
There's no need to update them manually. Instead:
189200

190201
1. Open Schema Visualizer at [http://localhost:9292](http://localhost:9292).
191202
2. Drag table nodes around to find a perfect arrangement.
192203
3. **CTRL** + **P**. It copies node positions JSON to your clipboard.
193-
4. Paste (**CMD** + **V**) JSON with positions to the [`src/config/tablePositions.json`](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/src/config/tablePositions.json) file.
204+
4. Paste (**CMD** + **V**) JSON with positions to the [`tablePositions.json`](https://github.com/sqlhabit/sql_schema_visualizer/blob/main/src/config/databases/bindle/tablePositions.json) file.
194205
5. PROFIT :beers:
195206

196207
#### E. Add table and column descriptions
197208

198209
Table and column descriptions are visible if you press `CMD` key and hover over a table or column name.
199210

200-
Add custom copy to the `"description"` keys [in table config files](https://github.com/sqlhabit/sql_schema_visualizer/tree/main/src/config/tables). Here's an example:
211+
Add custom copy to the `"description"` keys [in table config files](https://github.com/sqlhabit/sql_schema_visualizer/tree/main/src/config/databases/bindle/tables). Here's an example:
201212

202213
```json
203214
{

docs/snapshot.png

55 KB
Loading

0 commit comments

Comments
 (0)