mysql - Separate Users Across 2 Tables? -


i'm building ruby on rails application, i'm separating 2 sets of users:

  • buyers
  • sellers

currently built database both under users table with:

t.string "user_type",    default: "buyer", null: false 

there additional data need hold sellers , there few features/pages want sellers have access to, not buyers.

for example want hold bank details can pay sellers paid buyers (we hold payments few days ensure safe transaction). additional data may be:

  • account number
  • sort code

we not need store data buyers since use stripe payment.

do include data on current users table? or create new sellers table linked users table?

you can use 1 table , have differences in models. users, share many common features, e.g. authentication during sign_in, change password, etc.

class user < activerecord::base   ... end  class buyer < user   def buyer_specific_method_one     ...   end end  class seller < user   def seller_specific_method_one     ...   end end  

and add string field named 'type' user table. see single table inheritance.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -