Skip to Main Content

Organize Data Base & use a the value of a Varchar as column name.

User_K3U3TApr 26 2021

I am making a database for a fitness band for a school project.
And there is a table for the exercises, but the exercises don't share the same fields(for example Running has distance and duration but push-ups only have the number of push-ups). We came up with some ideas, cause we didn't want a table with a bunch of null fields.
Idea1: We would make a type of exercise table linked to the exercise one, which would store the column names of the generic fields, But he failed to use varchar as a column name in select as.
Idea2: We would use a case to make the right " select as " with the correct column names
What is the right way to solve this type of problem, and if it is the first one, how can I implement it?

Post Details
Added on Apr 26 2021