I have a small issue, if I were to have a table called, for example, emails
that contains emails and user information , how can each email have multiple questions and answers? Do I create a second table with secret questions and answers and use Foreign key
to associate them to each email? If so, do I associate them to each email_name
or id
?
If it's the latter, when inserting them, would I have to first insert the email and then, in the secret table
, insert email_name
/ id
again?
Example:
+----+------------------+----------+------------+----------+-----------------------+---------------+
| id | email_name | password | date | ph_num | secret_question | secret_answer |
+----+------------------+----------+------------+----------+-----------------------+---------------+
| 1 | jsmith@gmail.com | 123456 | 20.03.2013 | 56546513 | Name of first pet? | Rex |
| | | | | | Mother's maiden name? | Anna |
| 2 | asmith@gmail.com | 6021512 | 02.06.2015 | 23169584 | Real name? | Shaquesha |
| | | | | | First car? | BMW |
| 3 | rsmith@gmail.com | 123564 | 30.07.2008 | 13546849 | Secret number? | 90321 |
+----+------------------+----------+------------+----------+-----------------------+---------------+
I would prefer to create a separate table for questions and answers. And use primary key
of emailid
table as foreign key
in questions
table.
Use id
as primary key
and foreign key
in emailid
and questions
table respectively as id
is number and will be storing less memory compare to emailid
column.
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.