I didn't understand when in a table it could be unused id_field and when
it should be used!
In my db example in the tagtranslation's table I could remove id_field
and I could have FK_id_tag+FK_id_language like primary key and name right?
I didn't understand when in a table it could be unused id_field and
when it should be used!
In my db example in the tagtranslation's table I could remove id_field
and I could have FK_id_tag+FK_id_language like primary key and name
right?
I read this link https://www.quora.com/Should-every-table-in-a-database-have-an-ID-column
and I understood when I should use ID for example when I create a user
table where a user can change/modify his account without cancel it!
In a translation table I can feel free to don't use an id_field because
it's not necessary to change a translation!
Regards.
^Bart
It could be something like "to be or not to be" lol! :D
For example if I have tables like these:
tags
--------------------------
id_tag-a-a-a name
1-a-a-a seaview
2-a-a-a romantic
3-a-a-a cheap
languages
----------------------------
id_language name
1-a-a-a-a-a-a-a French
2-a-a-a-a-a-a-a Italian
3-a-a-a-a-a-a-a Spanish
tagtranslations -------------------------------------------------------------- id_tagtranslation FK_id_tag name-a-a-a-a-a-a-a-a-a FK_id_language 1-a-a-a-a-a-a-a-a-a 1-a-a-a-a-a-a-a-a Vista mare-a-a-a 2
2-a-a-a-a-a-a-a-a-a 2-a-a-a-a-a-a-a-a Romantico-a-a-a-a 2
I didn't understand when in a table it could be unused id_field and when
it should be used!
In my db example in the tagtranslation's table I could remove id_field
and I could have FK_id_tag+FK_id_language like primary key and name right?
No, it's not necessary in this case.a However, joining tables via
numeric columns (such as id) is much faster and more efficient than
doing it with character strings - especially when you concatenate two columns.
Plus, in the table you are joining you have to have the same columns
(type and size), so you would have to have both columns in the table you want to join to, also.
There are only very rare circumstances when I won't have an id column on
a data table.a However I will have it on a link table for a multi-multi relationship.a In that case the primary key would be the two columns containing the numeric id from each table.
No, it's not necessary in this case.a However, joining tables via
Ok, in my case and in other cases like it it's not necessary to use id column but... read below...
numeric columns (such as id) is much faster and more efficient than
doing it with character strings - especially when you concatenate two
columns.
if the use of a column id can help the db to be much faster and more efficient than when you use character strings or when you concatenate
two columns I don't understand why someone "love" to don't a column id!
--Plus, in the table you are joining you have to have the same columns
(type and size), so you would have to have both columns in the table
you want to join to, also.
I didn't know it because I always used tables with id column!
There are only very rare circumstances when I won't have an id column
on a data table.a However I will have it on a link table for a
multi-multi relationship.a In that case the primary key would be the
two columns containing the numeric id from each table.
Ah ok!
Thanks for your reply! :)
Regards.
^Bart
Yes, you don't need the id_tagtranslate, as you have two foreign keys
that can be used in combination as a primary key.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 63 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 492975:37:03 |
| Calls: | 840 |
| Files: | 1,301 |
| D/L today: |
16 files (28,385K bytes) |
| Messages: | 264,959 |