--- type: concept status: stable related_pages: ["[[B07_wf4_DesignDetail/B07_frontend]]", "[[B08_wf5_Quantity/B08_frontend]]", "[[B09_wf6_Estimation/B09_frontend]]"] last_updated: 2026-07-12 source: raw/guidelines/db_schema.md --- # DB: 구조물/수량/산출물 테이블 ← [[overview]] ## structures (배치 구조물) | 컬럼 | 타입 | Null | Key | Default / Extra | |---|---|---|---|---| | `id` | `int(11)` | NO | PRI | `auto_increment` | | `project_id` / `cross_section_id` | - | - | MUL | FK→projects / cross_sections | | `structure_type` | `varchar(100)` | YES | | 낙석방지책 / 계간수로 / 돌붙임 등 | | `chainage_m` | `float` | YES | | 구조물 배치 체인 시점 거리(m) | | `location` | `varchar(50)` | YES | | 좌 / 우 / 종단 등 배치 위치 | | `length_m` / `width_m` / `height_m` | `float` | YES | | 길이 / 폭 / 높이 규격(m) | | `material` | `varchar(100)` | YES | | 구조물 재질/자재 | | `quantity` / `unit_price` | - | YES | | 수량 / 단가 | | `design_notes` | `longtext` | YES | | 특기사항 등 메모 | | `structure_data_path` | `varchar(500)` | YES | | 세부 구조 상세 데이터 파일 경로 | | `last_modified_by` | `int(11)` | YES | MUL | FK→users.id (최종 수정자) | | `created_at` / `updated_at` | `timestamp` | - | | 생성 / 수정 일시 | ## quantity_items (수량 산출 항목) | 컬럼 | 타입 | Null | Key | Default / Extra | |---|---|---|---|---| | `id` | `int(11)` | NO | PRI | `auto_increment` | | `project_id` | `char(36)` | NO | MUL | FK→projects.id | | `category` | `varchar(100)` | YES | | 토공 / 구조물 / 포장 / 배수 등 공종 | | `item_name` / `unit` | `varchar` | YES | | 품목 항목명 / 단위 (㎡, m 등) | | `quantity_design` / `quantity_actual` | `float` | YES | | 설계 수량 / 최종 반영 수량 | | `unit_price` / `total_price` | `float` | YES | | 단가 / 총 금액 | | `standard_reference` | `varchar(255)` | YES | | 품셈 근거 코드/출처 | | `computed_at` / `quantity_data_path` | - | YES | | 계산 일시 / 상세 산출근거 데이터 파일 경로 | | `data` | `longtext` | YES | | 계산 세부 과정 통계 JSON | ## outputs (최종 견적/도면 산출 세션) | 컬럼 | 타입 | Null | Key | Default / Extra | |---|---|---|---|---| | `id` | `int(11)` | NO | PRI | `auto_increment` | | `project_id` | `char(36)` | NO | MUL | FK→projects.id | | `output_type` | `varchar(100)` | YES | | `estimation_excel`/`drawing_dxf`/`report_pdf`/`all_bundle` | | `status` | `varchar(50)` | YES | | `GENERATING` ➡️ `COMPLETE` / `FAILED` | | `generated_by` / `generated_at` | - | - | MUL | 생성자 FK / 생성일시 | | `version` | `int(11)` | YES | | 산출 버전 | | `outputs_directory_path` | `varchar(500)` | YES | | 산출 파일 번들 디렉토리 경로 | | `metadata` | `longtext` | YES | | 기타 도면 스케일 등 정보 JSON | ## output_files (개별 산출 파일 리스트) | 컬럼 | 타입 | Null | Key | Default / Extra | |---|---|---|---|---| | `id` | `int(11)` | NO | PRI | `auto_increment` | | `output_id` | `int(11)` | NO | MUL | FK→outputs.id | | `file_type` | `varchar(50)` | YES | | `xlsx`/`pdf`/`dxf`/`dwg`/`json`/`zip` 등 | | `original_filename` | `varchar(255)` | YES | | 원본 파일 식별 이름 | | `output_file_path` | `varchar(500)` | YES | | 개별 파일 저장 경로 | | `file_size_mb` / `download_count` | - | YES | | 파일 용량 / 다운로드 누적 카운트 | | `created_at` | `timestamp` | NO | | 생성일시 | ## quantity_items 총비용 계산 예 ```sql SELECT SUM(quantity_actual * unit_price) AS total_cost, category FROM quantity_items WHERE project_id = :project_id AND deleted_at IS NULL GROUP BY category; ```