// Creating references
// You can also define relaionship separately
// > many-to-one; < one-to-many; - one-to-one
기존 db.iogram
Table Item {
id int [pk, increment]
member_id int
//하나의 매니저는 여러 아이템 등록 가능
name varchar
type varchar
width long
height long
material_id list
weight long
color_id int
manufacture_id int
thumbnail image_file
}
Table Attachment{
id int [pk, increment]
item_id int
attatched_type int
is_show boolean
// is_show가 true면 보여주는 값
deleted boolean
//deleted가 true면 삭제처리된 애
//사실상 진짜 삭제는 안된 애임
writer varchar
comment varchar
created_at timestamp
}
Table Image{
id int [pk, increment]
item_id int
original_name varchar
unique_name varchar
created_at datetime
}
Table Material {
id int [pk, increment]
name varchar
code varchar
}
Table Manufacture {
id int [pk, increment]
name varchar
code varchar
}
Table Manufacture_part {
id int [pk, increment]
manufacture_id int
name varchar
code varchar
}
Table Route {
id int [pk, increment]
item_id int
//Route가 참조하는 아이템
is_power boolean
//가장 최신 라우트인지
//아이템이 반영하는 workflow 등은 최신 라우트의 것
type varchar
workflow varchar
lifecycle_status varchar
member_id int
approval int
reviewer int
//개정된 횟수 카운팅
//얘 따라서 Item revision갱신
revised_cnt int
}
Table Color {
id int [pk, increment]
name varchar
code varchar
}
Table Member {
id int [pk, increment]
name varchar
position varchar //직위
status varchar //직책
department varchar
phone_num varchar
email varchar
}
Table RouteProduct {
id int [pk, increment]
member RouteProductMember
}
Table RouteProductMember {
id int [pk, increment]
routeProduct_id int
member_id int
}
//멤버 - role 다대다 관계 맵핑 테이블
Table MemberRole{
member_id int
role_id int
}
Table RoleType{
//관리자인지 일반사용자인지 구분
id int [pk, increment]
role_type enum
}
//한 아이템에 여러 색깔
Ref: Item.color_id < Color.id
// 한 아이템의 제조사는 여러 제조사 가능
Ref: Item.manufacture_id < Manufacture.id
// 한 아이템의 재료부품은 여러 재료부품 가능
Ref: Item.material_id < Material.id
// 아이템의 라사는 라우트의 라싸 반영
Ref: Item.member_id > Member.id
//아이템의 썸네일은 하나의 이미지
Ref: Item.thumbnail - Image.id
Ref: Route.member_id - Item.member_id
Ref: Route.approval < Member.id
Ref: Route.reviewer < Member.id
Ref: Route.item_id < Item.id
Ref: RouteProduct.member < RouteProductMember.id
Ref: Member.id < RouteProductMember.id
// 한 manufacture 에 여러 part 속한다
Ref: MemberRole.role_id < RoleType.role_type
Ref: MemberRole.member_id < Member.id
Ref: Manufacture_part.manufacture_id > Manufacture.id
Ref: Attachment.item_id - Item.id