Search code examples
phpmysqldatabasedatabase-normalization

Storing Universities in MySQL


We are building our site and we are constantly adding new universities. I have a class that manages a lot of this. The question is, when people register, should we store the university they attend as the full string in the database, or convert each university to a unique int and store this, or create a new table of all the universities and just add them in manually as we add more schools to our system, then just store the primary_key of the chosen school in the users table? The easiest would be just to store the string. But I feel this may be inefficient.


Solution

  • I think storing the full string every time is very inefficient. I would tackle this by storing just the universityId number for each user, and then use SQL querys to retrieve whatever information you need.

    This way you will avoid duplicity in your data (e.g.: Different users from the same university entering different strings)