#๐Ÿ”’ Database design questions using flask-sqlalchemy...

9 messages ยท Page 1 of 1 (latest)

left sequoia
#

Here is the code

models.py
https://paste.pythondiscord.com/ABUQ

In the image I uploaded I have 2 tables the User and VerificationEmailToken tables.

A little background information.

I am using VerificationEmailToken in an 1 to 1 relationship once per User because every other field and mainly email_token field a is used once per User due to being one form for the email_token. Also I am deleting the email_token before a new email_token is created. And I only want a max of 5 for every column in VerificationEmailToken. To do this I added attempts_token_tried which has a max value of 5.

1st question.

Does it make sense for User and VerificationEmailToken to be an 1-1 relationship? Or should I make User and VerificationEmailToken an 1-Many relationship even though I only ever have 1 email_token at a time and only allow the user to try 5 times?

2nd question

Should I turn route_token_1 and route_token_2 into an its own table? RouteTokens would be the Many and User would be the One.
I only need 2 route_tokens no more no less so can I keep it the same?

zealous bronzeBOT
#

@left sequoia

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

thick raft
#

Does it make sense for User and VerificationEmailToken to be an 1-1 relationship?
I don't think so -- what if a given user needs to do the email dance more than once? Presumably you don't want to reuse the token, as it might have gotten leaked.

left sequoia
#

The token is just for the form and I delete the token everytime it is tried or expires. And only allow a total of 5 deletions + expiration.
Also I eventually after some time reset the attempts_token_tried to 0

#

Do you want me to show more code I mean my routes and some functions to get a better idea what I am talking about

#

Can you ping me so I get the message when you respond thanks

left sequoia
#

@thick raft ?

zealous bronzeBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.