asteriks's avatar

Basic issues of diagramming the database

Hello.

I have a basic question regarding how to structure tables with Laravel. That is, I have the general user table and a table with the user's contact data.

The proposal is the following

 $a = Schema::create('user', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('citizen_number')->unique();
            $table->string('name');
            $table->string('last_name');
            $table->string('password');
        });
    }

this is the other table:

 $a = Schema::create('user_contact ', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('user_id')->unique();
            $table->string('email');
            $table->string('city');
            $table->string('street');
           $table->string('phone');
		   $table->foreign('user_id')->references('id')->on('user');
        }

My question is the following, I have always seen that the email goes in the user table and here they have diagrammed it in the user contacts table. What do you think? it should be in user table? I see it as the email is related to the password so it should go in the same table but I don't know if it is a strong argument for them to change it.

0 likes
2 replies
jlrdw's avatar

Yes the users table since it's tied to login, unless you change to using username.

1 like
asteriks's avatar

@jlrdw thanks.

in this case the login is tied to citizen_number. So the email does not intervene in the login, but in the registration and in the password change. That makes me doubt.

Please or to participate in this conversation.