0

I would begin coding a school management theme project soon and am looking to keep the DB neatly organised. In this pursuit, since the students could be thousands in a school, would it be a good practice to have so many entries in the wp_users table by creating a separate user_role : students'? Or should I create a separate table to store the students' login data?

Please guide someone. Thanks.

2
  • I would note that you should use a plugin instead of a theme for data structure and handling. Themes are for displaying information and frontend styling/HTML. This is plugin territory
    – Tom J Nowell
    Commented Sep 21, 2021 at 19:30
  • @Tom thank you very much. I'm sorry I saw this valuable info so late. :) Commented Nov 27, 2021 at 11:08

1 Answer 1

0

In this pursuit, since the students could be thousands in a school, would it be a good practice to have so many entries in the wp_users table by creating a separate user_role : students'?

A separate user role will make no difference to site performance or scalability.

Or should I create a separate table to store the students' login data?

This is a very bad idea.

Creating a separate table to store the user login data would just result in the same problem but in a new table. It would also instantly break 99% of plugins and require large rewrites of fundamental parts of WordPress core. The end result would have the same performance or worse, but have a very high development cost, and a large ongoing maintenance cost.

If you need to store data that doesn't have a column in the user table, use user meta instead.


Thankfully the problem you're asking about doesn't exist until you reach user counts you're unlikely to ever experience.

Are you expecting tens/hundreds of millions of active users? If so you will encounter other issues long before you ever reach that point. WP installations with user numbers of 9 figures do exist, at those levels the biggest obstacles are not the size of the user table ( though it does break pagination on the admin user listing ).

The one issue I do foresee, is if you want to display every user all at once on the same page without pagination. The problem however has nothing to do with the database. You can only receive so many database results at once before you run out of memory to store them in PHP, or time to generate the HTML and send it to the browser.

7
  • Thank you so much. Yeah they won't be more than a few thousands. :D But I was reading about the entire password hash problem with new tables. How do I go about hashing the passwords on wp_create_user function? And more importantly, how to 'link' the login form to check users in this new wp_students table rather than the default wp_users? Thanks again for the patience. Commented Sep 21, 2021 at 19:33
  • messing with password hashing is a great way to compromise the security of password hashing. it's rarely a good idea to roll your own security schemes, and you may replace security mechanisms with inferior or broken versions based on incomplete or outdated advice. In particular I strongly advise against a wp_students table, it will not improve your security, performance, or scalability. If you need to store additional information about a user, use user meta. A custom table is usually a sign that something has gone wrong or that you have unique data requirements.
    – Tom J Nowell
    Commented Sep 21, 2021 at 20:20
  • Also new questions are new questions, this is not a discussion forum thread. If this answer answers your question please consider marking it as the correct answer
    – Tom J Nowell
    Commented Sep 21, 2021 at 20:21
  • I would also keep in mind that unless you are well versed in database design and know the ins and outs of your database engine and table schemas, your custom table will not improve performance, or security. Just use users + user meta. Given the question you asked here, I would steer clear of custom tables, they are not the make everything fast fix that some people make them out to be.
    – Tom J Nowell
    Commented Sep 21, 2021 at 20:23
  • Wonderful. Thank you for the detailed clarification. Btw, your personal webpage is very resourceful. I'll keep an eye on it :D Commented Sep 22, 2021 at 5:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.