Save to the bank who edited profile

Asked

Viewed 60 times

0

I’m developing a system that registers employees of companies.

In this system I have the staff tables and users.

Table employees have the data

id|nome|empresa|data_cadastro|user_view|user_edit

User table have the data

id|nome|empresa

The User when accessing the system with email and password, saves the session of the user ID.

I would like it when users view the employee profile, their ID is recorded in the employee table in the user_view column. That in the case are at least 5 users, to know who saw each profile.

How to write to the employee table? To display which users have already seen your profile. Same function to know if the employee profile has been edited by any user. I can write an ID at a time through an Insert in the table, but how to write multiple ID in a single column, or another way that can perform the same process.

2 answers

1

I think the ideal would be to create a new table and in it every time someone requests this page, you record the user id and the data you need, to easily locate, type, you could create a management screen where the responsible user performs the query and get the logs from it.. You wanted something like audit ? to know who changed the register ?

You also have to think about "growth" and if the company has more users? This way you passed, you will need to add another field in the table and then if it has many users it would be impractical.. and this way that you suggested I do not see a way to record all access... without creating a table of access logs...

  • It wouldn’t look too big on that bench. I thought about creating another column in the employees table, with the user name, and only insert ID value, then just consult in the bank and make a comparison between this column and the user ID to display.

  • Thinking like you said... there will be some questions... how will you maintain this data? imagine that the user diego, can change these data more than once.. not to mention that if everyone edits the record, they also won’t know what the last change was.. in my opinion the ideal would be even another table.. log..

  • there will be no slowness because the banks today are geared to this, you can index in the searches, when you create this table, think about creating fields as date of registration and date of modification, beyond the employee id of course, for you to have this information when you need..

1


For this case you need to create a new table where you will put the id_employee and also the id_user and when it accessVoce records in it the users who will view because there is no way Voce record several Ids in the same field.

You would have to create a text field and save like an XML but many databases this will have a limit and Voce would also have a lot of manual work in this second hypothesis.

  • As the flow of registrations is very large, it would not be a viable alternative, because there are many daily registrations, the system would be cumbersome and slow.

  • Do not need to worry about this, creates the table and creates the appropriate keys and can believe this will not be any kind of problem regarding the speed and size of the database.

  • Okay, here we go! Create a table calls logs with columns usuario_id | funcionario_id - and each time the user accesses it records the ID’s. But how would you do to query and display? Search for employee ID displays user Ids, need to search how many times that employee ID appears and display user id.

  • First the Voce table creates both Ids as Unique because it does not need to save several times the same information and then just select * from log Where id_funcionario = "ID" and Voce will have all users or the other way to know all the employees that the user looked at.

  • Varchar or Int?

  • You create the same as the original function and user table

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.