MySQL version : 5.7
Hello. I am working on a new django Project.
For the meanwhile,
I brought 2 tables.
Auth(1st Table) is containing user data(like id, email, password, name, etc.)
Paper(2st Table) is containing research paper information.
The Paper table has 10 columns for user permission. The only 10 users can read the paper, so I have a model for the table like;
class DocDetail(models.Model):
no = models.AutoField(primary_key=True)
doc_id = models.CharField(null=False, default="", max_length=255)
doc_name = models.CharField(null=False, default="", max_length=255)
doc_pw = models.CharField(null=False, default="", max_length=255)
view_perm_1 = models.IntegerField(null=True)
view_perm_2 = models.IntegerField(null=True)
view_perm_3 = models.IntegerField(null=True)
view_perm_4 = models.IntegerField(null=True)
view_perm_5 = models.IntegerField(null=True)
view_perm_6 = models.IntegerField(null=True)
view_perm_7 = models.IntegerField(null=True)
view_perm_8 = models.IntegerField(null=True)
view_perm_9 = models.IntegerField(null=True)
view_perm_10 = models.IntegerField(null=True)
folder = models.CharField(null=False, default="", max_length=255)
url = models.CharField(null=False, default="", max_length=255)
status = models.IntegerField(null=True)
action_exp = models.DateTimeField(null=True)
date_updated = models.DateTimeField(null=True)
view_perm columns are indicating Auth Table's user_id.
I want to select all columns of the Paper table and user data which linked to each view_perm column with 1 query.
I think I am pretty much wrong with modeling.
I can do select with 10 join, but it doesn't look right. Is there any better idea to make this works?
I am pretty new to SQL, so please guide me to right direction.