0

I have a table (stations) containing TV station names that are then used via FK in other tables. I was wondering if there is a convention or preferred way to name its columns.

Option A: id, name

Option B: id, station

Pro A: It is very descriptive in the full context (stations.name)

Pro B: makes it more descriptive when used without the table prefix (station vs name).

Chris
  • 13,100
  • 23
  • 79
  • 162
  • 2
    "name" is a lousy name. – jarlh Mar 08 '17 at 11:55
  • @jarlh but it is the logical property name. Consider each row as an object. A station object could have more properties (stations: [ {id: 1, name: "ABC", viewers: 123456, owner: "Corp LLC."} ]) I can't see why name is not a proper choice for the information it contains – Chris Mar 08 '17 at 12:02
  • check this out:http://stackoverflow.com/questions/7662/database-table-and-column-naming-conventions – TheGameiswar Mar 08 '17 at 12:02
  • @Chris "Consider each row as an object" is a bad idea. Rather consider each row as a proposition. Objects are represented by PK and FK values. A row represents a fact about one or more objects. – reaanb Mar 08 '17 at 12:44
  • @reaanb Ok, I agree, but the argument about the naming is the same regardless of considering it an object or part of one/many object/s – Chris Mar 08 '17 at 13:53
  • @Chris Option C: **station_id, station_name**. I don't recommend mindlessly prefixing all fields with the table name, rather the point is to distinguish unique domains (since station ids and names aren't interchangeable with e.g. channel ids and names). I would not add channel_ in front of a station_id FK in a channel table. However, I would add an additional prefix when the role of a column needs to be clarified, e.g. if a table has multiple columns of the same domain. – reaanb Mar 08 '17 at 15:47
  • Another, more controversial approach is **station, station_name**. This reinforces what I said about objects being represented by PK and FK values, but it seems most people prefer to use _id as a suffix for surrogate keys. – reaanb Mar 08 '17 at 15:52

0 Answers0