GithubHelp home page GithubHelp logo

rana's Introduction

DB設計

usersテーブル

Column Type Options
name string null: false, index: true
email string null: false, unique: true

Association

  • has_many :posts, dependent: :destroy
  • has_many :likes, dependent: :destroy
  • has_many :comments, dependent: :destroy
  • has_many :tags, through: :user_tags
  • has_many :user_tags, dependent: :destroy
  • has_many :followed_users, through: :relationships, source: :followed_id
  • has_many :relationships, foreign_key: "follower_id", dependent: :destroy
  • has_many :reverse_relationships, foreign_key: "followed_id", clas_name: "Relationship", dependent: :destroy
  • has_many :followers, through: :reverse_relationships, source: :follower_id
  • has_many :groups, through: groups_users, dependent: :destroy
  • has_many :group_users, dependent: :destroy

postsテーブル

Column Type Options
content text null: false
image_name string
user_id integer null :false, index: true, foreign_key: true

Association

  • belongs_to :user
  • has_one :group
  • has_many :likes, dependent: :destroy
  • has_many :comments
  • has_many :tags, through: :post_tags
  • has_many :post_tags, dependent: :destroy

groupsテーブル

Column Type Options
user_id integer null :false, index: true, foreign_key: true
post_id integer null :false, index: true, foreign_key: true

Association

  • has_many :users, through: group_users
  • has_many :group_messages
  • has_many :group_users

group_usersテーブル

Column Type Options
user_id integer null :false, index: true, foreign_key: true
post_id integer null :false, index: true, foreign_key: true

Association

  • belongs_to :user
  • belongs_to :group

group_messagesテーブル

Column Type Options
content text null :false
image_name string
group_id integer null :false, index: true, foreign_key: true
user_id integer null :false, index: true, foreign_key: true

Association

  • belongs_to :group
  • belongs_to :user

likesテーブル

Column Type Options
user_id integer null :false, index: true, foreign_key: true
post_id integer null :false, index: true, foreign_key: true

Association

  • belongs_to :user
  • belongs_to :post

commentsテーブル

Column Type Options
content text null :false
user_id integer null :false, index: true, foreign_key: true
post_id integer null :false, index: true, foreign_key: true

Association

  • belongs_to :user
  • belongs_to :post

post_tagsテーブル

Column Type Options
tag_id integer null :false, index: true, foreign_key: true
post_id integer null :false, index: true, foreign_key: true

Association

  • belongs_to :post
  • belongs_to :tags

user_tagsテーブル

Column Type Options
tag_id integer null :false, index: true, foreign_key: true
user_id integer null :false, index: true, foreign_key: true

Association

  • belongs_to :user
  • belongs_to :tag

tagsテーブル

Column Type Options
name string null :false, index: true, unique: true

Association

  • has_many :posts, through: :post_tags
  • has_many :post_tags, dependent: :destroy
  • has_many :users, through: :user_tags
  • has_many :user_tags, dependent: :destroy

relationshipsテーブル

Column Type Options
follower_id integer null :false, index: true, foreign_key: true, unique: true
followed_id integer null :false, index: true, foreign_key: true, unique: true

Association

  • belongs_to :followed, class_name: "User"
  • belongs_to :follower, class_name: "User"

rana's People

Contributors

ryosuke071111 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.