Need help understanding this SQL (generated by doctrine) -


I'm actually reading but it probably will be more of a SQL quesiton, originally, this one has many, unidirectional relationships Is considered to be the model. I think that PHP code (in that link), such a user has several phononodes.

The question is from SQL, it seems that 1 user can have many phone calls and 1 phone number is of 1 user only. Am i right

  Make Table User (ID INT AUTO_INCREMENT Not Zero, Primary Key (ID)) Engine = InnoDB; Create tabular users_phonenumbers (user_id INT not tap, phonenumber_id INT not zero, unique index users_phonenumbers_phonenumber_id_uniik (phonenumber_id), primary key (user_id, phonenumber_id)) engine = InnoDB; Create a table phone number (id int aangrément null, primary key (id)) engine = indodebi; Optional table users_phonenumbers Add foreign keys (user_id) Reference User (ID); Optional table users_phonenumbers Add foreign keys (phonenumber_id) reference phone number (ID);  

Do I just need to simplify the database ... below ... do not need to join tables and what not?

  User (id, name) phonen (id, user [frk], number)  

Correct, these are two valid approaches to the same problem and yes, unique index on users_phonenumbers means that each phone number can only be of one user .


Comments