I got this problem:

* User have many Candies (**1:M**),
* one of the Candies can have flag **primary**
* only one candy per user can be primary

Which way is better solution to do primary flag?

### solution1:

Users

```
| id  | name |
| 1   | Joe  |

```

Candies

```
| id | user_id | primary |
| 1  |  1      | true    |  
| 2  |  2      | false   |

```

### solution2:

Users

```
| id  | name | primary_candy_id |
| 1   | Joe  | 2                |

```

Candies

```
| id | user_id |
| 1  |  1      |
| 2  |  2      |

```

---

**Notes to Soluion 1**

* I got everything related to Candy in Candies table
* faster query if I check if any Candy is primary (don't have to join)
* If User got 100 candies, this way he have 99 of them *false* and only 1 meaningful *true* => 99 unnecessary column records

**Notes to Solution 2**

* this way I'll have only one column record (saves 99 other)
* If I want to check if the Candy is primary, I need to do join on client table
* let say I introduce more 1:M tables with primary flag related to User: icecreams, chocolates, junkfoods,... this way I'll have 4 more columns in User

This is more SQL problem but I'm using Rails 3.\* in project so best practice opinions from this field welcome