简体   繁体   中英

Single table or multiple database tables

Am working on a web app and I currently have three models 'User', 'Profile', 'CorporateProfile'. The Profile model serves a User who has an individual account and CorporateProfile for an corporate account. The tables; profiles and corporate_profiles have similar fields; street, city_id, phone, state_id. Am trying to figure out if it will be better to use a single profiles table to handle both User type accounts.

DB Schema

Users Table

  • id
  • email
  • password
  • first_name
  • last_name
  • name

Profile Table

  • id

  • user_id

  • photo

  • sex

  • dob

  • state_id

  • city_id

  • street

  • school_id

Corporate Profiles Table

  • id

  • user_id

  • logo

  • industry_id

  • state_id

  • city_id

  • street

  • description

it depends on what you main purpose is. If you have many selects on your database it may be better to keep these values in the tables. Otherwise it may be more valueable to make a new entity (ProfileInformation or something like that) to have shared values in one table

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM