I will briefly summarize the DB design I learned today.
-The entity considers the timing when the data is registered.
-Active Hash can be used for pull-down.
-Columns using ActiveHash are integer type. Also, it is easy to understand if you add _id
to the column name.
-It is better to handle postal codes and telephone numbers as string type.
-Use the data type for the date.
-The column that can contain both numbers and characters is a string type.
-Do not give column names that can be judged by table names.
ex) In the users table, do not set the column name to user_name. It can be name.
ActiveHash
・ Describe the connection on the ER diagram.
-Introduce gem'active_hash'.
-If there is a one-to-one relationship, describe has_one
as the parent and belongs_to
as the child.
・ The judgment of parent and child is that if the other cannot exist, the one that does not exist is the "child".
・ Think carefully about where to put the foreign key.
Recommended Posts