2
I am beginner in systems development, and I would like to know if the table of users of the system could establish relations with other tables, as for example, the table of company.
2
I am beginner in systems development, and I would like to know if the table of users of the system could establish relations with other tables, as for example, the table of company.
3
Yeah, no problem at all.
For example, I could associate users to companies using foreign keys:
CREATE TABLE EMPRESA (
EMPRESA_ID INT PRIMARY KEY,
-- Coloque aqui as colunas que você gostaria que EMPRESA tivesse
)
CREATE TABLE USUARIO (
USUARIO_ID INT PRIMARY KEY,
EMPRESA_ID INT FOREIGN KEY REFERENCES EMPRESA(EMPRESA_ID),
NOME VARCHAR(255),
-- Coloque aqui as colunas que você gostaria que USUARIO tivesse
);
Associations can also be made for other tables. It all depends on the desired goal.
Note that I did not use a specific SQL syntax. The idea is just to illustrate what can be done.
Browser other questions tagged sql database
You are not signed in. Login or sign up in order to post.
It is that I want to make a system in which the user relates to the call table and company. Then I was in doubt if it dismembers this table, because it will contain the user, type of user and related fields, for some other specific table.
– Vinícius Venancio dos Santos
In its place, it would make the call table relate to company and user. Nothing prevents this from being done in the modeling.
– Leonel Sanches da Silva
I modeled the call table by relating to employees (containing the login fields) and users (containing all company information and password, and login fields). In case I want to add a comment table, how would I model? Since the comment can be made by the user and an employee, and foreign keys cannot be null? For example, as I know it was the user who commented, and not an employee?
– Vinícius Venancio dos Santos
This would already be content for a new question.
– Leonel Sanches da Silva
I’ll do it! Thanks for your attention
– Vinícius Venancio dos Santos