A
A
Alexander Semikashev2014-01-05 20:17:22
MySQL
Alexander Semikashev, 2014-01-05 20:17:22

How will be better

Tell me please. I read a lot about database normalization, but a question arose.
There is a table name: id, name, birthday
There is a table album: id, id_name, name
In id_name I insert id from name.
What is better to insert an id and do Join in the request, or is it better to insert the name into id_name at once (taking into account the fact that the name will not change)?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis, 2014-01-05
@denis_vl

The question is a little unclear. But if you are talking about how to make a bunch, then it is better by a numeric ID. That is, name->id = album->name_id. For the simplest link by ID, you do not need to create an index. And of course it is better to use InnoDB tables with foreign keys.

K
Kerman, 2014-01-05
@Kerman

If to do in a smart way:
1. It is necessary to make the intermediate table between name and album. There will be only two fields id_name and id_album. Both fields must be indexes. unique indexes.
2. Left join should be done double when selecting by album. Yes, and by name too.
3. name rename to Artist. This is the list of performers, right?
4. Add a Band table. Keep the name of the group in it.
5. Add id_band to album table.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question