Search code examples
androiddatabasestringdeclare

Anything wrong with declaring variables like this?


So there are sort of 2 questions here.

In my database I need 18 fields because in golf there are 18 holes (so 18 to store hits for each hole.) Second I need to store the yardage for each hole (so thats 18 more.)

My question is, right now I am declaring them all as follows:

public static final String KEY_H1 = "h1";
public static final String KEY_H1Y = "h1y";
public static final String KEY_H2 = "h2";
public static final String KEY_H2Y = "h2y";
public static final String KEY_H3 = "h3";
public static final String KEY_H3Y = "h3y";

etc.

h1 being hole 1 h1y being hole 1 yardage

Is there a better way to do this? Additionally, in the on create I will have to call h1 h1y h2 h2y h3 h3y etc.

Thanks in advance!

EDIT: 1. Will this tax the system a lot in terms of, cause the application to bomb out or run slower? 2. In the future, will this make it a pain to update the database?


Solution

  • You could instead of having a "golf game score" table, have a "hole score" table. This table could then contain an int column for the hole, another column for yardage, and another game_id column.