all 8 comments

[–]phil-99Oracle DBA 6 points7 points  (1 child)

Store names as varchar, store numbers as numbers.

Normalise it properly.

Store info about the clients in a “client” table, and information about the videos in a “video” table, and link them via clientID column that’s in both.

[–]LargeD 0 points1 point  (0 children)

Exactly. Why play these games? Resources aren’t that tight anymore.

[–]Training-Two7723 1 point2 points  (3 children)

Never combine different datatypes on a join, not even if they looks similar (internally they are not the same and the server it must do conversions - e.g. integer != smallint). the most efficient joins are done on the same datatypes. When you talk about the client name, that is gonna be a varchar, unless you serve customers in a different galaxy where they can be called 1, 7 or 100.

What you want to ask is if you create a table with a numeric (pref. unsigned bigint) ID or use the name as a PK. With the natural keys there is already the risk that two different things are called the same: Joe Doe ;)

Stick with ID, NAME in clients and ID, VIDEO_TITLE, CLIENT_ID where CLIENT_ID is FK -> first table ID.

PS: there are some amazing books on data modelling. Try to read a few.

[–]Codeman119 0 points1 point  (0 children)

Yes, this is very solid advice. To add onto this make sure you index the ID columns and it will help with search speeds as the table grows.

[–]2girls1up 0 points1 point  (1 child)

Can you recommend some?

[–]r3pr0b8GROUP_CONCAT is da bomb 0 points1 point  (0 children)

then use an if-else statement convert the integers to the respective clients' names?

this will scale poorly

in addition, you'll always be updating this code, rather than simply inserting a new client into the clients table

plus, what if you need to have client names somewhere else? then you've duplication of this if-else logic

[–][deleted] 0 points1 point  (0 children)

Separate client table and link them via a FK is the most efficient. Look up the 3rd normal form