简体   繁体   中英

Android room schema relation

With my android room database, I have 2 tables: order and service , where service is either: massage, haircut, or spa. An order could have 1 or more services, I want my service table to just have my 3 different services. What is the right way to do this?

Should I be using join ? Foreign key ? @relation ? embed ?

I don't want any copies of services in my order table, because the detail/price of service could change at any time.

You should just use foreign key for 1 to many relation (one order : multiple services). This may help you and here is official documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM