DynamoDB Event Scheduling Table Structure - aws-lambda

I'm building out a scheduling app, where users can invite other users to events. However, I'm having a little trouble figuring out how I want to set up my tables.
Since DynamoDB is a NoSQL database we want to try to keep data that is related, in the same table. However, this problem gets a bit more confusing because some events for my app may have roles, such as organizer, planner, etc. Therefore, I want users for an event to be able to accept the invitation to the event with specific roles.
Therefore, in this case, would I want to use two tables, one that stores the event (UUID, Name, etc.) and the other that has the users attending events (UUID of Event, Username, etc.) or use one table?
Plus, when I create my get request to fetch the event data if I use two tables, would I have to query the user table to get the number of people attending that event or should I store that value in the event table, and then when a user signs up, add a new row to the users table, and update the number of people attending in the event table?
For the app I am using Lambda functions on AWS.
Any help would be appreciated, thanks!

You can have
userid as hash-key
eventid as range-key
role as LSI
You can also have a GSI on event-id to query based on eventid
sample table:
user1, event1, organizer
user2, event1, planner
user3, event1, attendee
user4, event1, attendee

Related

Implementing row based access based on role

I have created a table that contains Ticket information, with an id, message body, user id and department id.
I would like to be able to limit access to these tickets, such that only users from the corresponding department can access the relevant tickets, and can not view other department's tickets.
I have attempted to make an updatable view for each department and granting select on this, but it does not work very well.
Is there a simple way to achieve this kind of role based access?

Messaging with two user tables in Laravel

I am developing a system in which it will have a chat system between two user tables: the clients and the engineers. My problem is how to make these two tables communicate in one message table with regard to registering the sender ID and recipient ID since both can change and are in different tables.
My initial thought for this was two tables where I would use the polymorphic relationship:
chats
id
client_id
engineer_id
messages
id
chat_id
senderable_id
senderable_type
receiverable_id
receiverable_type
content
What would be the most recommended way to solve this problem?
First of all, the following its the generic way that I see to create a chat schem. It'll works to a chat with 2 users or more than 2 users.
Note, the user_chat table its the pivot table between users and chats. You can define an alias to that table, like "participants", because it what it means. You can add more attributes to chats table, but basically need to know the creator.
Finally, the secret in messages table is just to get the sender id from users table, because sender and receiver are relative concepts in this context.
Another more simple and reduced way to do it (if you are trying to make a chat with only 2 users) is:

Design DB for chats between users

I have one problem with designing database structure for my app. I have 3 models: Events, groups and users.
Relations:
Events - Users - many to many.
Groups - Users - many to many.
There will be available one chat withing group and one inside event. Additonally in the near future I am going to implement chats between two or more users.
I'm a bit confused what is the best way to design it. I created Chat model and many to many relation between chat and users.
First idea: The members of group and event chats will be stored in respectively event_users and group_users tables. Only chats between users will be stored in chat_users.
Second idea: chat_users will be synchronized with event_users and group_users tables. The advantage of this way is that I will have simple separated logic to manage chats and there will be not many complicated queries to DB.
Thanks for any feedback or maybe other ideas.
I believe that Chat has a polymorphic association with Group and Event (and maybe User as well). Some solutions to the problem are provided here:
https://www.slideshare.net/billkarwin/practical-object-oriented-models-in-sql/29-Polymorphic_Assocations_Solutions_Exclusive_arcs
Could something like this work?
ChatUser
id
user_id
chat_id
Chat (exclusive arcs method)
id
event_id (nullable)
group_id (nullable)
description/etc
ChatMessage
id
chat_id
user_id_from
user_id_to (nullable)
date
message
Assumptions made:
event/group can contain multiple chats
user can belong to a group but not to group chat
Besides, Laravel comes with a native polymorphic relation handling solution. It could fit here as well.
User can participate to an event and event can have many users who participate to that event, in this specific case we need to use as Many to Many relation Laravel One to Many Relation
event_user
id
event_id
user_id
User can be member of many group and a group can avec many member, in this case we need a Many to Many relation Laravel Many to Many Relation
group_user
id
group_id
user_id
chat can be related to an event or a group, so we save the type of the chat witch can be either Event or Group and the corresponding ID of that event or group. so if we have a particular chat we can retreive all users related to that chat through the corresponding event or group it depending of the chatable_type in each case, to learn more see Laravel Many To Many Polymorphic Relations
chats
id
name
chatable_id
chatable_type
we need also one table to save all conversations for specific chat
messages
id
chat_id
message
created_at
and for users chat you can create a separate table witch can save the related information about that chat specifiquely
conversations
id
sender_id
receiver_id
message
all sender_id and receiver_id will be foreign key witch reference some id on users table

Correct Many to Many friends relationship for users

What is the correct way to relate users in parse to one another as friends?
I also want users to be able to query other users but not see all fields, like emails. Is there a way I can create a view on the users table with cloud code, and only return this to the client code?
I was thinking I can create a friends table that will have two columns with 2 pointers, 1 for each user.
thanks for any advice.
I was thinking I can create a friends table that will have two columns with 2 pointers, 1 for each user.
I'll do that too, with a status column to handle pending, blocked...etc
I also want users to be able to query other users but not see all fields, like emails.
You have to add a privateData column on user with ACL restricted to owner only, which would contain private infos such as emails...etc

Facebook graph api Events and Venue Information, sometimes it only returns venue id when the event was created in a known venue

I'm creating an app in Titanium that uses the Facebook Graph API to get all the users events, however, the venue information, it only brought to me, after I was very specific about the field, and some times, a lot of the times, when the Event was created in a known location, it only brings the venue_id, and when I query the venue(via http://graph.facebook.com), then it gives me the venue location details, more importantly, the latitude and longitude of the thing.
Is it possible to bring the information of the venue in the same response?
Also, it only brings the events that the user is attending, is there any way to show the events recommended to him also?
Ti.Facebook.requestWithGraphPath('me/events?limit=5000&fields=id,owner,name,description,start_time,end_time,location,venue,privacy,updated_time', {}, 'GET', function(e) {
obj = JSON.parse(e.result);
Ti.API.info('Events: '+JSON.stringify(obj));
}}); // Facebook Events
Also, it only brings the events that the user is attending, is there any way to show the events recommended to him also?
Not sure what exactly you mean by “recommended” … if you mean events the user has been invited to, then you can query the FQL event_member table with the user id.
You can kind of “join” the info from the table above with the event table by selecting from that using WHERE eid IN (SELECT … FROM event_member WHERE …)
Is it possible to bring the information of the venue in the same response?
Using a multi-query you can do it, similar to as it is described here: FQL: query for event table returns venue.name instead of venue.id

Resources