1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【個人開発】プロフィールサイト【ポートフォリオ】

1
Posted at

はじめに

ポートフォリオとして簡単な学習内容を記録するプロフィールサイトを作成します。

テーブル定義

users(ユーザー基本情報)

列名 型(例) 必須 制約 目的/備考
id BIGINT PK, Auto Increment ユーザーを一意に識別する内部ID
name VARCHAR(100) 表示名
email VARCHAR(255) UNIQUE ログイン用メールアドレス
password_hash VARCHAR(255) ハッシュ化したパスワード
introduction TEXT 自己紹介文
avatar_image_url VARCHAR(500) アバター画像のURL
created_at TIMESTAMP 作成日時
updated_at TIMESTAMP 更新日時

programming_languages(ユーザーが持つ“項目”(言語))

列名 型(例) 必須 制約 目的/備考
id BIGINT PK, Auto Increment 言語項目の内部ID
user_id BIGINT FK(users.id) この項目を作ったユーザー(ユーザーごとの管理にする)
category VARCHAR(20) frontend / backend / infra の固定3種
name VARCHAR(100) 言語名(自由入力)
created_at TIMESTAMP 作成日時
updated_at TIMESTAMP 更新日時

重複を防ぐ制約(重要)

  • UNIQUE (user_id, category, name)
    • 「同じユーザー・同じカテゴリで同じ言語名は追加できない」を実現

learning_records(学習時間:年×月×言語の時間を1行で管理)

列名 型(例) 必須 制約 目的/備考
id BIGINT PK, Auto Increment 学習記録内部ID
user_id BIGINT FK(users.id) 誰の記録か
learning_year INT 何年の記録か(例: 2026)
learning_month INT 何月の記録か(1〜12)
programming_language_id BIGINT FK(programming_languages.id) その“項目(言語)”の時間
learning_time_minutes INT 学習時間(分)
created_at TIMESTAMP 作成日時
updated_at TIMESTAMP 更新日時

重複を防ぐ制約(重要)

  • UNIQUE (user_id, learning_year, learning_month, programming_language_id)
    • 同じユーザーの同じ年同じ月に、同じ言語(項目)を二重登録できない
    • 「登録後に時間を増減」は、その1行の learning_time_minutes 更新で実現できる

リレーション(補足欄に書く用)

  • users(1) ── programming_languages(多)
  • programming_languages(1) ── learning_records(多)
  • users(1) ── learning_records(多)
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?