User table and User Information table, why should be divided into two tables, what are the general fields?

Source: Internet
Author: User
Save user information generally with two tables
User
Profile

I'd like to know what these two tables usually have.
User (id,name,email,^ ...)
Profile (ID,????)

What content is stored in the user, and what does it put into profile? such as password user name and so on in the user, is it, this has no standard?

Or simply all of them with a single sheet.

Tangled!!!

Reply content:

Save user information generally with two tables
User
Profile

I'd like to know what these two tables usually have.
User (id,name,email,^ ...)
Profile (ID,????)

What content is stored in the user, and what does it put into profile? such as password user name and so on in the user, is it, this has no standard?

Or simply all of them with a single sheet.

Tangled!!!

is for future consideration, this is a typical example of a vertical sub-table. Put text and other fields that do not sort filter into the secondary table. This design ensures that the performance degradation of the main table is not very serious when the data volume is increased.

In the database design, but also to consider the engine optimization problem, one of the main purpose of the table is to speed up the large data volume of access speed, such as the index table includes the primary key IDX, account password User level these basic fixed length fields, note is fixed length, detail table has associated IDX and other variable length, or BLOB field, MySQL accesses only table with fixed length field speed is the fastest

Personal understanding, User is to the login system with the information table, the content is simple, user name, password, and the other is the customer unit personnel information, here to save the user basic information, age, address and so on, the people here are mainly used for the system business use, not necessarily the landing user, for reference only.

According to the business different design is good

Each table represents a theme (subject), there is a primary key (primary key), the primary key determines the other columns functionally, and the primary key uniquely determines a record. is user and profile the same thing? What are their primary keys? Figure this out and you'll know how to design it.

The artificial ID is a concept introduced in the late stage of database physical design, and the model of logical design can only be established by using relational primary key. It's hard to see the relationship between the data itself when you start by thinking about the table name and labeling the ID.

Therefore, first of all to understand the needs, need to record which facts, and then consider how to build the table.

Table? Relationship? Database design?
Database design principles Please refer to the "Three Paradigms of database design", the basic goal is to reduce redundant information .

User table and profile table?
The only possible reason for this design is that 1 users will have more than one copy of the data.

Just a little bit, okay:
1 for a 1 relationship (assuming that 1 users have only 1 mailboxes), it should be saved in the same table (the mailbox column in the user table).
1-to-many or many-to-many relationships (assuming that 1 users can have n friends), a separate table should be built (with the ID of the user in the table and the ID of the friend).

1 lattice is only a message, 1 tables are the only relevant things, try not to keep the information repeated in multiple tables, which is the standard.

In addition, who said "Save user information generally use two tables" ?

Think, the main reason is to split the long data into another table, the table of the total length of the data fixed, the engine found fast

The user table is divided into two parts of the situation is not certain, depending on the system business logic, there are for a couple of cases, there is also the reason for database efficiency, when the data to modify the time must be the row level of the lock table (depending on the engine) This is often a large number of system access operation is fatal. So there is a vertical partition table, the use of information is not commonly used to separate this approach

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.