Home>
Summary

I asked a question like this and got advice, so I used it to define tables and relations .

Environment

Laravel 6.5.0
Homestead

What you did or made for the question Table registration

Table registration 2

Assumed ER diagram

ER diagram output by Laravel Entity Relation Diagram Generator

Testing with tinker

I want to ask

I can't tell if the relationship with the primary key/foreign key table in Laravel is correct, so please point out that the expected behavior has been made.

Because it doesn't make a decision, because the toTo is established with the business_hours table facilities table in the ER diagram output by the Laravel Entity Relation Diagram Generator, it seems that the HasMany relationship does not hold.

I want to pick up open and close from the Facility model, that is, I want to make it possible to get the business hours of the facility from the facility ID (facilites ID), although the table that registers the facility and business hours is separated That's it.
It looks like there is no problem when I look at the image verified with tinker, but I was worried about the above and asked the question.

Remarks
The password_reset part of the ER diagram output by the Laravel Entity Relation Diagram Generator is just the default when Laravel's Auth authentication is introduced.

Append

I will add that the question is difficult to understand.
From Previous Question to a simple wireframe and activity diagram for a system that expects to use the ER diagram for this question add to.

Source of the system i am trying to build

Tokyo Sports Facility Service

I want to make the following system based on the registration part of the above URL from the date and time of use.

Simple wireframe

Simple activity diagram related to the question I want to ask this time

The ER diagram I'm assuming is trying to make the above system, but the image is 3 images, but if you look at the 4th image (the library that shows the relationship after migration with Laravel), bussiness_hours belongsTo facilities The question is whether there is no problem at first glance as if the relationship of facilities hasMany bussiness_hours is established.

  

Does that mean that the parent table and child table have one-to-one data?
  Doesn't that mean you don't need to normalize it?

Regarding the comment

, the table is divided by facilities and bussiness_hours. It is the result of receiving advice that it is better to create a separate business hours table and relate it to the facility table.
In addition, I received a comment from the respondent of the previous question a while ago, and id that is not an Integrer should be set to Integer or BigInteger, and should be auto-incremented again, so we are considering it again.

This is the first time I have carefully considered the definition and design of a table in creating a deliverable in a month of Laravel, so in the first place I was advised about the possibility that the concept of relations is wrong and the advice I received in the previous question I'm very sorry that I didn't understand it and couldn't interpret it wrongly.

  • Answer # 1

    I don't think it makes sense to say that I answered the last time, but it looks like there is no problem with the current ER.

      

    Laravel Entity Relation Diagram Generator

    I ’ve never used this, so I guess it ’s speculation. Isn't BelongsTo, HasMany etc. generated from Model information?

    But I think that it is better to auto-increment with integer/biginteger type according to Laravel