Applications and Brands have many-to-many relationship. The best is to have separate Applications and Brands tables and a third table relating them to each other.
In your Media table, the Brand and Application columns will be references to their respective tables. Once this is done, the behavior you need should be straight forward and easily achieved.