오늘
✈️
안녕하세요! 🌍 어떤 여행을 꿈꾸고 계신가요?
✈️
휴양지부터 도시까지, 총 22개의 여행지와 DB 스키마·ERD를 준비했어요! 🌴🏙️🗄️
모두 보여줘! 💯
✈️
아래에서 원하는 카테고리를 선택하세요. DB 탭에서 SQL 스키마와 ERD도 확인하실 수 있어요!
추천 여행지
22개🔍
검색 결과가 없어요
다른 키워드로 검색해보세요
🗄️ 데이터베이스
Cloudflare D1 · SQLite-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- Travel Recommendation DB Schema -- Database: Cloudflare D1 (SQLite) -- Created for: 데이터베이스 최종과제 -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- 1. 카테고리 테이블 (휴양지 / 도시) CREATE TABLE categories ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, emoji TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP ); -- 2. 여행지 테이블 (메인 엔티티) CREATE TABLE destinations ( id INTEGER PRIMARY KEY AUTOINCREMENT, category_id INTEGER NOT NULL, name TEXT NOT NULL, country TEXT NOT NULL, tagline TEXT, image_url TEXT, best_season TEXT, budget_range TEXT, duration TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (category_id) REFERENCES categories(id) ); -- 3. 여행지 하이라이트 (1:N) CREATE TABLE highlights ( id INTEGER PRIMARY KEY AUTOINCREMENT, destination_id INTEGER NOT NULL, icon TEXT, description TEXT NOT NULL, sort_order INTEGER DEFAULT 0, FOREIGN KEY (destination_id) REFERENCES destinations(id) ON DELETE CASCADE ); -- 4. 태그 테이블 CREATE TABLE tags ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL UNIQUE ); -- 5. 여행지-태그 연결 (N:M 관계) CREATE TABLE destination_tags ( destination_id INTEGER NOT NULL, tag_id INTEGER NOT NULL, PRIMARY KEY (destination_id, tag_id), FOREIGN KEY (destination_id) REFERENCES destinations(id), FOREIGN KEY (tag_id) REFERENCES tags(id) ); -- 6. 사용자 테이블 CREATE TABLE users ( id INTEGER PRIMARY KEY AUTOINCREMENT, nickname TEXT NOT NULL, email TEXT UNIQUE, created_at DATETIME DEFAULT CURRENT_TIMESTAMP ); -- 7. 리뷰 테이블 (destinations + users 참조) CREATE TABLE reviews ( id INTEGER PRIMARY KEY AUTOINCREMENT, destination_id INTEGER NOT NULL, user_id INTEGER NOT NULL, rating INTEGER CHECK(rating BETWEEN 1 AND 5), comment TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (destination_id) REFERENCES destinations(id), FOREIGN KEY (user_id) REFERENCES users(id) ); -- 8. 즐겨찾기 테이블 CREATE TABLE bookmarks ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, destination_id INTEGER NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, UNIQUE (user_id, destination_id), FOREIGN KEY (user_id) REFERENCES users(id), FOREIGN KEY (destination_id) REFERENCES destinations(id) ); -- ─── 인덱스 ───────────────────────────────────────── CREATE INDEX idx_dest_category ON destinations(category_id); CREATE INDEX idx_review_dest ON reviews(destination_id); CREATE INDEX idx_review_user ON reviews(user_id); CREATE INDEX idx_bmark_user ON bookmarks(user_id); -- ─── 예시 INSERT ──────────────────────────────────── INSERT INTO categories (name, emoji) VALUES ('휴양지', '🌴'), ('도시', '🏙️'); INSERT INTO destinations (category_id, name, country, tagline, best_season, budget_range) VALUES (1, '몰디브', '몰디브', '에메랄드빛 바다의 천국', '12월~3월', '300만원~'), (2, '도쿄', '일본', '전통과 혁신의 도시', '3월~5월', '100만원~'); -- ─── CRUD 예시 ────────────────────────────────────── -- SELECT: 카테고리별 여행지 조회 SELECT d.*, c.name AS category FROM destinations d JOIN categories c ON d.category_id = c.id WHERE c.name = '휴양지' ORDER BY d.created_at DESC; -- UPDATE: 여행지 정보 수정 UPDATE destinations SET tagline = '새로운 설명', budget_range = '150만원~' WHERE id = 1; -- DELETE: 즐겨찾기 취소 DELETE FROM bookmarks WHERE user_id = 1 AND destination_id = 3;
🔗 테이블 관계 요약
| 부모 테이블 | 관계 | 자식 테이블 | 연결 컬럼 |
|---|---|---|---|
| categories | 1 : N | destinations | category_id |
| destinations | 1 : N | highlights | destination_id |
| destinations | N : M | tags | destination_tags (중간) |
| destinations | 1 : N | reviews | destination_id |
| users | 1 : N | reviews | user_id |
| destinations | 1 : N | bookmarks | destination_id |
| users | 1 : N | bookmarks | user_id |