Thanks Kostya for useful Links and Daniel for great explanation. On Nov 12, 4:08 pm, Daniel Drozdzewski <[email protected]> wrote: > On Fri, Nov 12, 2010 at 10:52 AM, pramod.deore <[email protected]> > wrote: > > Hi, Kostya Thanks. But I think it only override older value. what I > > want is > > > If suppose I have > > roomid:101 > > roomName:Hall > > switchid:202 > > switchName:AC > > > Now if suppose I insert a record as(101,Hall,203, Light) > > > then record is added as > > roomid:101 > > roomName:Hall > > switchid:202,203 > > switchName:AC,Light. > > > I hope you understand what I am trying to say. > > Pramod, > > to achieve the above you will need to change your data model. > It is obvious that in your case each room can have multiple switches. > By storing this data in the ROOM table, you are breaking few rules.(*) > > Create separate table for switches and additional table that maps from > roomid -> switchid > Then to "add" extra switches to a room, you either insert new switch > into switch table or just search for switchid, if added switch already > exists in your data and then add it to this table that achieves 1 to > many mapping between roomid and switchid. > > You have to have a look at data modelling and '1 to many' > relationships between entities. > > (*) we are talking data normalisation and various forms of this; By > normalising your data, you will improve consistency and reduce > duplication, but retrieval will cost you more time, since it will rely > on JOIN operations. This is not too optimised in SQLite... You will > have to make few judgement calls, but it will be dependant on your > particular problem. > > -- > Daniel Drozdzewski
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

