database design - DB structure: two tables or one? -


I have two pieces of data: 1) User and 2) Portfolio Each user has only one portfolio. In the registration process, the user must fill in the following fields:

  • First name
  • Last name
  • Porfolio title
  • Portfolio URL < / Li>
  • Password

At this time my DB structure looks like this:

  create tab 'user' (`id`int (11 ) Faucet AUTACCRment, `e-mail 'varchar (80) No, the password is not password varchar (128),' first name 'varchar (30) tap,' last name 'varchar (30) not tap,` ip' varchar (15) No tap, 'Last visit' int ( 10) No tap, 'Status' tinton (1) tap default' 2 ',' created 'int (10) tap, primary key (`id`), unique key id_UNIQUE` (` id`), unique key' email_uniec '(`Email`)) engine = InnoDB Authentication = 1 DEFAULT CHARSET = utf8; Tables' portfolio '(`user ID') (` 11 '),' title 'varchar (255) no tap,' url 'varchar (45) tap, `theme` tinton (2) tap default' 1 '` font' Tinto (2) tap default '1', 'footnote' varchar (255) is not faucet, 'featuret' tinent (1) tap default '0', primary key (`user id '), unique key' id_ UNIQUE` User ID), unique key 'url_UNIQUE` (`URL')) engine = InDebbi default charge = UTF8;  

But now seeing the database, I think there is no reason for two different tables. The second thing is that I really do not want to mix user's fields and portfolio areas.

What will you do in this matter?

Any suggestion is appreciated.

Thank you!

The scenario in which you want to keep them separate:

  • Without a portfolio, a user can be present (Do you have other types of users who have a portfolio?).

  • A new portfolio can be made for a user who had no one.

  • Two users can swap portfolio (in fact it will be difficult because the user is the primary key of the portfolio).

  • You can support multiple portfolios per day, or many users per portfolios, or both.

  • You want to manage the SQL privileges to access some database users on a table, not others (but they do not have a database that has column-level privileges Or supports view-level rights).

  • You want to make a BA

  • You want to monitor the location consumed by two separate tables.

  • In fact, you want to actually use SELECT * instead of the column names, and you still have each of the columns Want to be able to choose subcontract? And you do not want to use ideas for it.

  • You want to take advantage of more than your INODAB buffer pool for display, and buffering smaller rows means that you store more rows than the same size buffer Tip: Declare the IP to int unsigned instead of varchar (15).


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -