Private chat application in laravel - database

How to implement database for private chat system between user and admin
ok,I have two table one is admin and second one is users
admin table
| id | name | email| phone_number | password |
user table
| id | name | email| phone_number | password |
Now How can I set up chats table between these two users??
chats table
id | user_to | user_from | messsag |
How chat table should look like??

There is no need of using two different tables of users. Just need to add a new field in user table to point out if the user is admin or not. Then you chat table logic will work
user table
| id | name | email| phone_number | password | admin (true | false)
chats table
id | user_to | user_from | messsag |
Alternatively you can go with a workaround like this:
admin table
| id | name | email| phone_number | password |
user table
| id | name | email| phone_number | password |
chats table
id | user_to_table | user_to | user_from_table | user_from | messsag |

Related

Candidate submission and placements SQL Server

May I know what is the best way to create a table structure in SQL Server that would store large amount of data as well retrieve the data easily, taking performance into consideration.
For example:
Candidates to Jobs (one-to-many or many-to-one)
Candidates Submitted to Jobs (many-to-many)
Candidates Placed to Job (one-to-one)
I've got 2 tables with few columns - like this:
+-------------+ +------------+
| Candidates | | Jobs |
+-------------+ +------------+
| CandidateID | | JobID |
| DisplayName | | JobTitle |
| JobTitle | | UserID |
| UserID | | CreateDate |
| CreateDate | +------------+
+-------------+
Now, I would like to create another table to store submissions and placements of Candidate(s) to Job(s).
Could someone give me few examples of how I can store this data.

Dynamic form field configuration in mvc

I have multiple employee groups in my project. Based on the selection of different employee group,submission form fields will differ in the view. If the fields are static then it is easy to do the CRUD operations. I need to create the fields dynamic in nature. I must be able to configure the form fields in SQL server table.For employee Group 1, 5 fields, for Group 2, 6 fields etc. If i want to add new field to any of the group in future also it should work. How can i achieve this?
Thanks
Have you considered using many-to-many relationship between tables Employees and Fields. Something like this:
You'll have a table that holds the list of all possible fields (first name, last name and etc). Then to connect the Employees table and the Fields table with many-to-many relationship you'll need some kind of table (EmployeesFields). Table EmployeesFields holds the value for the each field that employee has.
For example:
EMPLOYEES
+----+------------------+
| Id | CreatedAt |
+----+------------------+
| 1 | 02.08.2017 11:21 |
+----+------------------+
FIELDS
+----+-----------+------------------+
| Id | Name | CreatedAt |
+----+-----------+------------------+
| 1 | FirstName | 02.08.2017 11:24 |
| 2 | LastName | 02.08.2017 11:26 |
+----+-----------+------------------+
EMPLOYEESFIELDS
+------------+---------+-------+------------------+
| EmployeeId | FieldId | Value | CreatedAt |
+------------+---------+-------+------------------+
| 1 | 1 | John | 02.08.2017 11:34 |
| 1 | 2 | Doe | 02.08.2017 11:39 |
+------------+---------+-------+------------------+
I think this is the most simple solution. It just shows the basic idea. Modify it to fit your needs.

SQL Server database design users, groups, roles, memebers

I have the following SQL Server db with one table so far.
----------------
|Users |
----------------
| UserId PK |
| |
| Other fields |
----------------
I need to add few more tables to it which is not a problem but this is the goal:
---------------- ---------------- ---------------- ----------------
|Users | |Roles | | Teams | | Groups |
---------------- ---------------- ---------------- ----------------
| UserId PK | | RoleId PK | | TeamId PK | | GroupId PK |
| | | | | | | |
| Other fields | | Other fields | | Other fields | | Other fields |
---------------- ---------------- ---------------- ----------------
What I need to achieve is the following:
I have X amount of users
User1
User2
UserX
I have 3 roles only for all users to use in all teams and groups
Admin
Member
Visitor
One user can create X amount of teams
Team1
Team2
TeamX
One user can create X amount of groups
Group1
Group2
GroupX
Groups and Teams can have users assigned to them with different roles (Admin, Member, Visitor)
One user can belong to one or many team or groups
One user can belong to one or many roles
I have some hard time understanding the relation between those tables.
Here is what I managed to achieve based on the answer from #Robertas Valeika.
You need 3 more tables.
UsersRoles
UsersRolesGroups
UsersRolesTeams.
Relationships:
UsersRoles - UsersRolesGroups,
Groups - UsersRolesGroups
UsersRoles - UsersRolesTeams,
Teams - UsersRolesTeams
Users - UsersRoles,
Roles - UsersRoles.
And add FK to users in groups and teams tables to identify creator of group and team.

Using category attribute of a cfindex tag

I'm trying to index a database table using a <cfindex>. I also want to categorize the index based on the values of a column of the same table. No documentation I have come across clearly mention what the "category" attribute takes. Is it a column name or just any desire value and if the later then how do the index determine which record belongs to what category?
Thanks a lot in Advance.
| ID | CATEGORY | NAME | DETAILS | DATE |
| 1 | people | John | John details | 01/23/1980 |
| 2 | animal | Dog | dogs details | 02/22/1990 |
| 3 | people | Ben | Ben's details | 10/10/2006 |
| 4 | animal | panda | panda's details | 07/17/2009 |
The docs didn't make it clear, but if you are indexing a database and there is a column that you want to use for the category, just pass the name of the db column to the category attribute.

databases design

for example i have table users, which have 3 fields:
id - login - password
---------------------
1 | john | *****
2 | jack | *****
3 | jane | *****
now i want that each user could have his own settings.
So, do i need to create three different tables, like
user_N_settings:
id | key | value
-------------------------
1 | save_data | True
or i should create one big table for all users instead?
users_settings:
id | key | value | user_id
---------------------------------------------
1 | save_data | True | 2
2 | some_opt | False | 3
One table for all users. A table per user would be very wrong.
One table. If all the setting values are of the same type then it may make sense to create one row per setting. If the attributes are all very different then create one column per setting.

Resources