本文介绍了Android Room生成动态表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个供用户使用的表.用户创建一个类别,然后将Youtube视频分配给该类别.我目前有一个用户表,类别表(用户ID外键)和youtubevideo表(用户ID外键,类别外键).

I have a table for users. The user creates a category, and then assigns Youtube videos to the category. I currently have a user table, category table (user-id foreign key), and youtubevideo table (user-id foreign key, category foreign key).

我目前在类别和youtubevideo中查询用户的ID,但是我认为随着数据库的增长,这些查询可能会变得很繁琐.

I currently query the category and youtubevideo for the user's id, but I assume these queries could become burdensome as the database grows.

我想根据用户的ID(例如,用户ID)为每个用户的类别动态创建一个唯一的表.用户52具有表格-类别52和youtubevideos-52. Room是否可能或可行?

I would instead like to dynamically create a unique table for each user's category based off the user's id, e.g. User 52 has table - category-52, and youtubevideos-52. Is this possible or feasible with Room?

推荐答案

不是,Room使用annotations生成架构.在使用annotationProcessors进行编译之前,将处理注释.因此,无法在运行时生成表.

It is not, Room generates schema using annotations. Annotations are processed before compilation using annotationProcessors. Because of this it is not possible to generate tables at runtime.

这篇关于Android Room生成动态表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 20:32
查看更多