Using auto_increments to join MyISAM tables in MySQL -


As long as I've been writing php for a long time, it was always a skill I learned myself and I just hit Confidence of a little bit of confidence on the host!

MyISAM tables containing a MySQL db auth user and permissions :

  - ID (Auto increment) - Email permissions - ID (auto increment) - Name  

To join many-to-many in these tables (or one-to-many ), I've always used pull arrays in this way:

  user_permissions- id (auto increment) - user_id - permission_id  

(I know That's capable of the Nodb relationships, but this and More complex and more memory, so I want to be with my ISAM for the purpose of q)

My special question is: Is it wise to use tables of automatic growth using the keys To join, or should I generate my extra key?

I know that if a table gets contaminated then problems can arise and I have to rebuild, or if I start mirroring two DBS and the keys get out of sync.

I know that if I generate a unique hash for each line to join) then to create a hash and insert each data before it is new to check it's up Is on the side

How does everyone do this? Have you seen these issues in practical situations?

Thank you for your time!

Adam

This is usually the surrogate keys (created or automatically assigned There is a decision to use the values ​​made, which is of no value beyond being unique), and natural keys (keys that are being stored like Unit Name or Bank Account #).

In your case, it is not clear if there is any natural key that will work (user can change every aspect of the table - name changes after marriage, etc.). You want a natural key, if there is no relation, while still keeping the relationships is not likely to be key. In the periodic table of elements, there will be something like the element name ( au, he, es , etc.) (which is unlikely to be different from adding new ones, but hey, anything can happen. .)

For data corruption, backups are actually the best protection because anything can be corrupt. And in typical operations, whenever you migrate or synchronize you can always preserve the primary key. Using a detailed complex rental key will be more risky than the auto increment provided by the DB, because it includes (you have to make your unique sure, and possibly deal with the collision in a secure manner. ) ... and a truly generous surrogate key will not help in the case of corruption (there is no way to correlate it with the record).

A natural PK says that the user's e-mail will be very high- whenever every relationship has to be updated, changes in email, swapping email addresses between 2 accounts is complex, rather than broader standards than index intits But very less efficient. Trade-offs inclined in favor of auto-incharge key

Write a good one here:


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -