Should one stick to 1NF (and higher NF) rules for SQL even while using ORMs?
0
votes
0
answers
31
views
I am currently making a database in MySQL using the SQLAlchemy ORM. I followed the principles of 1NF until this point (atomised Data, no redundancy) but now I am tempted to add a few useful (though technically redundant columns).
1NF would prescribe using a Foreign Key Column in the Children table which points to an entry in the Parent table. However, for the sake of my front-end tasks, I was also thinking of adding a "Children" column in my Parent table that has the primary keys of all the children to that entry [Note that each parent has multiple children so this "Children" Column in the Parent Table essentially has a list. This will help me as I can simply use "parentXYZ.children" instead of having to query the Children table to get a list of all children to parentXYZ]. The "relationship" feature (paired with "back_populates") in SQLAlchemy even seems to suggest this is optimal.
Will this have any major issues down the line if I can be sure I will be using the same ORM forever?
I have just begun reading up on SQL so apologies if this question is trivial.
Resources I read through already:
1. https://docs.sqlalchemy.org/en/20/orm/basic_relationships.html
2. https://en.wikipedia.org/wiki/First_normal_form
Asked by Arya Vishe
(1 rep)
Jun 28, 2024, 11:01 AM
Last activity: Jun 28, 2024, 12:37 PM
Last activity: Jun 28, 2024, 12:37 PM