成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

在線數(shù)據(jù)庫關(guān)系圖設(shè)計(jì)工具 dbdiagram.io

yuanzhanghu / 3135人閱讀

摘要:為了簡(jiǎn)單快速地把這十幾張表設(shè)計(jì)并定義出來,我找到了一個(gè)可以在線設(shè)計(jì)數(shù)據(jù)庫關(guān)系圖且可以導(dǎo)出的工具。這個(gè)時(shí)候這個(gè)在線的數(shù)據(jù)庫關(guān)系圖工具就排上用場(chǎng)了。

前段時(shí)間,筆者在設(shè)計(jì)某個(gè)系統(tǒng)模塊的時(shí)候,需要增加十幾張表。

為了簡(jiǎn)單快速地把這十幾張表設(shè)計(jì)并定義出來,我找到了一個(gè)可以在線設(shè)計(jì)數(shù)據(jù)庫關(guān)系圖(database relationship diagram)且可以導(dǎo)出DDL SQL的工具——dbdiagram.io。

dbdiagram.io是holistics.io這款商業(yè)產(chǎn)品的社區(qū)版。

dbdiagram.io使用DSL語言,可以簡(jiǎn)單快速地創(chuàng)建數(shù)據(jù)庫關(guān)系圖。

這款工具的操作界面也非常簡(jiǎn)約并具有設(shè)計(jì)感:

有時(shí)候我們需要在關(guān)系型數(shù)據(jù)庫中設(shè)計(jì)一些表,以便實(shí)現(xiàn)我們的業(yè)務(wù)功能。

或者我們對(duì)某個(gè)系統(tǒng)的表結(jié)構(gòu)不是很熟悉,希望畫個(gè)圖表示一下這些實(shí)體之間的關(guān)系。

又或者我們希望把設(shè)計(jì)好的數(shù)據(jù)庫關(guān)系圖直接轉(zhuǎn)化為DDL SQL。

而且我們不想使用復(fù)雜的工具,付出高昂的學(xué)習(xí)成本。

也不想用太重的工具,占用內(nèi)存。

這個(gè)時(shí)候這個(gè)在線的數(shù)據(jù)庫關(guān)系圖工具就排上用場(chǎng)了。

語法

下面介紹一下它的語法。

定義表的語法如下:

Table users {
  id integer [pk]
  username varchar [not null, unique]
  full_name type [not null]
  .....
}

如果表名太長(zhǎng)還支持取別名:

Table longtablename as t_alias {
  .....
}

定義外鍵支持如下三種關(guān)系:

< : One-to-many
> : Many-to-one
- : One-to-one

并且提供了3種定義外鍵的方式:

Ref name-optional {
  table1.field1 < table2.field2
}

Ref name-optional: t1.f1 < t2.f2

Table posts {
  id integer [pk, ref: < comments.post_id]
  user_id integer [ref: > users.id]
}
例子

下面以電商系統(tǒng)常用的幾張表作為例子演示一下它的用法。

當(dāng)你登錄自己的Google賬號(hào)以后,可以把你設(shè)計(jì)好的圖形保存到線上,這樣就可以通過一個(gè)唯一的鏈接訪問 : https://dbdiagram.io/d/5cc910...。

這里是DSL:

Table orders {
  id int [primary key]
  user_id int [not null, unique]
  status varchar
  created_at varchar
}

Table order_items {
  order_id int
  product_id int
  quantity int
}

Table products {
  id int [primary key]
  name varchar
  merchant_id int [not null]
  price int
  status varchar
  created_at varchar
  category_id int
}

Table users {
  id int [primary key]
  full_name varchar
  email varchar [unique]
  gender varchar
  date_of_birth varchar
  created_at varchar
  country_code int
}

Table merchants {
  id int [primary key]
  admin_id int
  merchant_name varchar
  country_code int
  created_at varchar

}

Table categories {
  id int [primary key]
  cat_name varchar
  parent_id int
}

Table countries {
  code int [primary key]
  name varchar
  continent_name varchar
}

Ref {
  orders.user_id > users.id
}
Ref {
  order_items.order_id > orders.id
}

Ref {
  order_items.product_id > products.id
}

Ref {
  products.merchant_id > merchants.id
}

Ref {
  products.category_id > categories.id
}

Ref {
  categories.parent_id > categories.id
}

Ref {
  users.country_code > countries.code
}

Ref {
  merchants.admin_id > users.id
}

Ref {
  merchants.country_code > countries.code
}

這里是導(dǎo)出的數(shù)據(jù)庫關(guān)系圖PDF:

總結(jié)

最后總結(jié)一下dbdiagram.io的特點(diǎn):

DSL : 使用簡(jiǎn)單的DSL語言即可定義數(shù)據(jù)庫關(guān)系圖

Google Account :使用Google賬號(hào)可以在線保存設(shè)計(jì)好的圖

Online :不需要安裝軟件,方便快捷,而且支持拖動(dòng)和調(diào)節(jié)

Import/Export : 支持導(dǎo)出DDL SQL和PDF,支持導(dǎo)入外部數(shù)據(jù)

Share : 可以生成一個(gè)分享鏈接,方便團(tuán)隊(duì)成員協(xié)作

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/39022.html

相關(guān)文章

  • ArcGIS 柵格函數(shù)在線調(diào)用詳解

    摘要:使用柵格函數(shù)支持直接在前端使用柵格函數(shù)來重新渲染影像服務(wù)。針對(duì)數(shù)據(jù)在柵格函數(shù)模版編輯器中使用渲染地貌函數(shù),并且設(shè)計(jì)好結(jié)果的渲染方式。配置柵格函數(shù)模版可以在兩種情況下進(jìn)行。 ArcGIS 柵格函數(shù)在線調(diào)用詳解 導(dǎo)讀:ArcGIS從10.0版本開始引用鑲嵌數(shù)據(jù)集,并且第一次在影像中加入柵格函數(shù)(raster functions),使得影像的呈現(xiàn)和信息提取與GIS緊密的結(jié)合起來,簡(jiǎn)單的影像功...

    894974231 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<