dbflute / dbflute-intro

introduction of DBFlute, provides e.g. first setup, GUI handling
Apache License 2.0
7 stars 6 forks source link

can select preset statement #279

Open jflute opened 3 years ago

jflute commented 3 years ago

reference

http://dbflute.seasar.org/ja/manual/reference/dfprop/schemapolicy/index.html#hyperexample

table.statement

FK, IX, PK, UQ

## 制約 (e.g. PK, FK) ##
# _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
# 例えば FK なら、FK_[テーブル名]_[FKカラム名 or 相手のテーブル名]
; if tableName is $$ALL$$ then fkName is prefix:FK_$$table$$

# MySQL では FK も INDEX に含まれるため、INDEX名も同様のチェックが必要
; if tableName is $$ALL$$ then indexName is prefix:IX_$$table$$ or prefix:FK_$$table$$

# ERDツールによっては、PK制約名を付けづらいケースもあるかも (なら諦めるもアリ)
; if tableName is $$ALL$$ then pkName is prefix:PK_$$table$$

# UQ制約名の付け方は、色々なパターンがありそう
; if tableName is $$ALL$$ then uniqueName is prefix:UQ_$$table$$
# _/_/_/_/_/_/_/_/_/_/

DB comment

choose one... "alias is $$tableName$$" ?

## コメント ##
; if alias is $$tableName$$ then bad => 論理名がテーブル名と同じじゃダメ
; if alias is $$comment$$ then bad => コメントが論理名と同じじゃダメ
; if tableName is $$comment$$ then bad => コメントがテーブル名と同じじゃダメ

column.statement

FLG column

choose one... "_FLG is not null" or "dbType is bit" ?

## FLGカラム ##
# _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
; if columnName is suffix:_FLG then alias is suffix:フラグ => FLGカラムなら論理名は "なんとかフラグ" にしよう
; if columnName is not suffix:_FLG then alias is not suffix:フラグ => FLGカラムじゃないのに、"なんとかフラグ" という論理名なの?

# MySQLのメタデータとしては、boolean は bit になる
; if columnName is suffix:_FLG then dbType is bit

; if columnName is suffix:_FLG then column is notNull => nullのフラグはやめよー
; if columnName is suffix:_FLAG then bad => _FLG に統一
# _/_/_/_/_/_/_/_/_/_/        

DATE column

choose one... "_DATE is date" ?

## DATEカラム ##
; if columnName is suffix:_DATE then alias is suffix:日 => DATEカラム(時分秒のない日付)なら論理名は "なんとか日" にしよう
; if columnName is not suffix:_DATE then alias is not suffix:日 => DATEカラム(時分秒のない日付)じゃないのに、"なんとか日" という論理名なの?
; if columnName is suffix:_DATE then dbType is date => なんとか_DATEなら、日付ということで date に

## DATETIMEカラム ##
; if columnName is suffix:_DATETIME then alias is suffix:日時 => DATETIMEカラムなら論理名は "なんとか日時" にしよう
; if columnName is not suffix:_DATETIME then alias is not suffix:日時 => DATETIMEカラムじゃないのに、"なんとか日時" という論理名なの?
; if columnName is suffix:_DATETIME then dbType is datetime => なんとか_DATETIMEなら、日時ということで datetime に

comment

choose one... "alias is $$columnName$$" ?

## コメント ##
; if alias is $$columnName$$ and columnName is not pattern:(URL|UUID|CUID) then bad => 論理名がカラム名が同じなのはダメ。ただ、URLとかはしょうがないので not pattern に列挙
; if alias is $$comment$$ then bad => コメントが論理名と同じなのはダメ
; if columnName is $$comment$$ then bad => コメントがカラム名と同じなのはダメ
jflute commented 3 years ago

button candidates:

table.statement:
[FK name] [Index name] [PK name] [Unique name] [strict TableAlias]
column.statement:
[_FLG notNull] [_FLG type boolean] [_DATE type date] [_DATETIME type datetime]  [strict ColumnAlias]
jflute commented 3 years ago

This is a requirement for first release.

table.statement

FK name

; if tableName is $$ALL$$ then fkName is prefix:FK_$$table$$ => fkName means constraint name of foreign key

Index name

normal pattern: ; if tableName is $$ALL$$ then indexName is prefix:IX_$$table$$

if MySQL: ; if tableName is $$ALL$$ then indexName is prefix:IX$$table$$ or prefix:FK$$table$$ => MySQL automatically creates an index for a foreign key

column.statement

FLG dbType

; if columnName is suffix:_FLG then dbType is bit => MySQL meta data provides "bit" type even if boolean

FLG notNull

; if columnName is suffix:_FLG then column is notNull => Let's avoid a three-valued boolean column.

DATE dbType

; if columnName is suffix:_DATE then dbType is date => dbType means "column data type"

DATETIME dbType

; if columnName is suffix:_DATETIME then dbType is datetime => dbType means "column data type"