Collective web chat - sql-server

I need to develop a web chat with one "advanced" feature: grouping chat - like the Skype's chatting system.
The theory is trivial, but in practice it is very hard. Since last friday I was thinking about this, but I have no idea of how I can apply this architecture. Basically I need a database's design with a good structure without store redundancy.
Ok....... so far it seems simple, but now I'll introduce our main feature: history by user.
I can create one chat with 2 users. Ok, two days passed and I want to add a third user to join the conversation. The chat's history for him will be different: he will not be able to view old messages in that chat.
Wonderful, huh? Remember, friends: I can not use XML to store the history locally. I NEED to user a SQL Database. In my case, I'm using SQL-Server, from Microsoft.
Can you all understand my problem? If yes, isn't trivial, huh? Ok. Can someone think how I can solve this problem? I'm going crazy!

Actually the problem is trivial. Storing it in XML would be the real problem.
Users (UserId, Name)
Chat (ChatId, ChatName)
ChatParticipation (ChatParticipationId, UserId, JoinChatMessageId, LeaveMessageId)
ChatMessages (ChatMessageId, ChatId, UserId, Message)
By adding the ChatParticipation table you will know exactly which is the ChatMessageId at which the user joined the chat (JoinChatMessageId) and don't show him messages prior messages. LeaveMessageId can track when he left the chat room. Multiple join/leaves can be modeled as separate participation.

You haven't said what language (PHP etc).. So it's kinda hard, but, if I was creating this from a PHP point of view I would have the chat based upon id's. www.site.com/chat.php?id={id} and then have a way to accept / decline the user accordingly.
I can create one chat with 2 users. Ok, two days passed and I want to add a third user to join the conversation. The chat's history for him will be different: he will not be able to view old messages in that chat.
Why not give each message a date and a time, and then when a user member enters the chat, they can only see the messages from this date/time? This could work in theory.
So if I joined the chat today at 15:20pm then I can only see messages on or after 15:21.
Your main problem is going to displaying the messages in real-time, because it is a web application..
Good luck!

I am not sure, whether I understand your problem correctly.
As far as I understand it, you need 4 tables:
user (userid, username),
conversation (conversationid, conversationtitle),
user_conversation (userid, conversationid)
post (userid, conversationid, text)
user stores all users registered in your system. conversation stores all conversations. user_conversation maps theusers to the conversations they are allowed into. Post stores the posts a user has made in a certain conversation.
Now you can simply retrieve data from post by user, by conversation or both. If you dont want a user to see older posts, add a date field.
Regards
Luigi

Related

Firing multiple api calls at once

I'm struggling to find the right words to convey what I'm looking for in my research, so I thought I would ask the stackoverflow community. I am looking for best practices to create records in different tables at once.
An example would be, user registration. Say you need to create 6 records for that user when they sign up, which need to connect. By connect I mean in the sense that if a user and team were created on user registration, the userID would need to be included in the team's members array. So the records need to fire in order so the relationship is properly recorded. So user would need to be created first, then the team record so I can add the userID to the team's members. Also note that the user record would need to be updated later on (after the team's record is created) with the teamID under the user's teams.
So as you can see it feels a bit all over the place. Currently I have multiple API calls being fired on user submit. While I have this working using redux, firebase and react — I foresee a lot of potential errors happening and feel as if I am not doing this in the most efficient way. I want to do this correctly and happy to do the research, I'm just not exactly sure what I am looking for. I was hoping for some guides, information, search terms, etc — basically anything to help me understand this concept more throughly if that makes sense.
This is a perfect candidate for GraphQL and a backend that handles it properly. Take KeystoneJS for example. You could do a single create user and handle it all internally via the hooks system. You can also do nested creates / connects all in one mutation and KeystoneJS will take care of all of it for you if there are nested operations. For example you can create object A, then create object B in one mutation. It'll create B, then A, then connect A to B... with no extra work on your end. I just give this as a single example of a tool you can use. Here is an example mutation that Keystone just handles:
mutation CreateUser {
createUser(data: {
username: "test"
organization: {create: {
title: "test"
}}
})
}
Notice organization is created inside of the user mutation.
Yes, I think the best practice is to have your back end, whatever it is, do the work. It will fail if it bumps into an issue and clean itself up. Otherwise, it produces a positive response. I hope this is helpful...
For alternatives, since this is a pretty open ended question... I've also created a nestJS back end. That works great too, but it's a lot less opinionated with fewer built in solutions, so you do a lot more work (but it's more flexible). Any CMS should give you control over this (Strapi seems to be taking off... I just ran into too many bugs with it).

REDCap - reporting data back to user

I'm looking for a simple solution for a cooperative project where specimens will be mailed to me, and I would report several measurements back to the sender.
I need the originating site to fill out a form with some basic information (specimen ID, collection dates, shipment tracking #, etc). Then I need to let the site know I received the shipment - via the same form. Then, after some analytics, I need to report 3 numerical values (biomarker levels) back to the site.
Someone recommended REDCap for this project. I know I can do data collection with REDCap (the initial requisition form), but can I also report the values back with REDCap?
It appears I found the solution, by talking to a REDCap expert. In case someone is interested, here's basic outline:
Create two forms: one for requisiton, another one for reporting data back to user.
Invite REDCap users to my project and give them read-only rights to the second form.
Put other users in Data Access Groups, so they only can see the requisitions (and results) from their own group.
This might work, but I decided to not go this way. In REDCap, an user has all rights by default, and I would have to limit them. In my application there is too much potential for data breach due to mistake in assigning rights and DAGs.
Another solution would be to use REDCap with an email alert module enabled.
Configure a project with two forms:
One for the client to enter the information you need from them, and make that form anonymous - no user account needed, and collect an email address from them (to return results). For the example below let's call this form [request].
The second form will be for you to enter the biomarker levels and whatever else you need to. This form only needs to be viewable and editable by you. Let's call this [results].
Then, if you have the email alerts module enabled (and you'll have to speak with your REDCap administrators about that) you can configure it to automatically email someone with information contained in the record, and to set the logic by which the email is sent.
This solution and the one you were recommended are the same with respect to form design, but they differ in the way the results are shared with the requestor. This solution does not require the user to have an account to access the results. I personally think the other solution (with user roles and DAGs) is the better solution.

Export multiple database records to iCal or gCal

I'm building a simple scheduling application for a client. It allows teachers to create a calendar of assignments for their students. I'd like to offer the ability for a student to add ALL assignments to their calendar at one time. Say there were 20 assignments over a 4 week period. This functionality would allow the student to download a single file, or follow a certain feed, to add all 20 assignments to their calendar at one time.
In my head this would be a single iCal file, but I'm not sure if iCal works that way. Alternately, each course /course/basket-weaving-101_51/ would have an RSS feed /course/basket-weaving-101_51/cal/ that could be followed.
Does anyone have experience with this, or could offer guidance?
Yes, one feed program that accepts parameters via the url could be used to offer a subscribeable calendar feed at whatever level of detail you wish. I say subscribeable as that, at a student level ... /student_id_or_name?feed=ics would offer the students the most convenient solution. They could subscribe once and then all the courses assignments that they are signed up for all courses over time could automatically appear as their calendar app refreshes the feed.
A single assignment could also offer a feed of the one 'event'. But that should probably be imported into their main calendar, rather than subscribing!
Note subscribing is different to importing - your help instructions need to make that clear as it is up to the user what they do with the feed.
Import(or add to calendar) is a once-off and will not update with new events/assignments.
Subscribing as a separate calendar I find much preferable as most calendar apps will let one check and uncheck the calendars as you need them. I have mykids timetables subscribed (and public holidays etc) but that's a very busy view, so often I just untick them
for a cleaner view.
You need to get familiar with the treatment of ical by the different calendar clients (outlook, webmail) before you can decide how best to target them. In general, they have two modes for treating ical: "accept an invitation" and "subscribe to an internet calendar".
The big advantage of "Accept an invitation" is that your events go into the user's calendar, and generate reminders and so on as if the user had created the event. The disadvantage is that you need to send your invitations one "event" at a time by email, and, particularly in Outlook, they may need to be viewed as mail before they appear in the calendar. If you're sending out 20 or more assignments, this may feel like spam to the recipient.
"Subscribe to an internet calendar" is a little misleading in that an ical feed is not a feed. You put the "whole calendar" on a website, and the client poles the website. Outlook and webmail clients are generally happy to display these calendars, but "importing" the events into the user's own calendar is a bit clunky. Gmail and webmail display the info on the same grid by default. Outlook displays a new grid for each calendar.
Modifications are a bit more complex for the subscription scenario. You will likely want to regenerate the whole calendar for affected students, whereas in the invitation scenario you just send one mail with the changed event.
Even so, if you have a database with courses, students and enrolments, you could do a nice little app that generates an ical per student, names it with their student number, and whacks it in a calendars folder. The student subscribes once to http://myuniversity.com/calendars/12345.ical, and each semester all their assignments are automatically in their web calendar.
Be careful with the subscription link. If tens of thousands of students subscribe to (pole) a dynamically generated calendar, you are going to have a lot of needless processing, and quite likely a performance headache. You want to be generating static files, then let your webserver negotiate with the client whether they need to be resent.

Making a database of searchable profiles using forms

This is more a general topic on implementation. Basically what I want to do is allow one group of users to create a survey from a html form and allow them to post this for a second group of users to see.
I would like the second group of users to be able to fill out the forms and submit them to whoever posted the survey. I would like whoever posted the survey to be able to filter the results (by say age, sex, or other variable in the form) and I would like the first group to be able to use their form in subsequent surveys without having to re-enter data?
I have basic knowledge of HTML and CSS so my question would be how is the best way to implement this? Is it even with forms? What languages would I need to learn?
Not sure I quite get the hang of what you're trying to do but for starters there's plenty of free survey creation tools out there such as http://www.surveymonkey.com/ that might do some/what you need.
Google Docs should allow you to input the survey data into a spreadsheet.

DNN module sugestions needed, form/reg, pyment, emailing

i need a module that is kind of a cross between a registration module and a form module.
it need to allow for custom form fields to be saved to the DB and work as part of a flow such that once data is entered by the users they click next and see the data to confirm it is correct. at this point they should have the option to edit the data if they notice an error or continue to a payment page.
the payment page needs to have a module that can integrat with payment gateways liek paypal and accept credit cards. once credit card data is entered and the transaction is complete a custom email with a unique userNumber needs to be sent to the user.
i figure im lookign at three separate modules for this typeof work flow. but i hope since this is a standard type of register, pay, email confirm operation there may be a single module i can confugure to meet my needs.
thoughts? suggestions?
Have you looked at DNM RAD by DotNet Mushroom?
http://www.dotnetmushroom.com/DNMRADGeneral/GeneralInformation/WhatisDNMRAD/tabid/2347/Default.aspx
I have not had a use for this yet, but it is a module that I have on my short list in case the need comes up. They do state that they can work with pament gateways.
Good luck.
You might have to be somewhat flexible with your work flow if you want to used 100% canned modules.
FormMaster is a pretty good form solution. You can write to existing database tables, structure SQL tables or just the default is an XML file. It doesn't go through a preview before saving though.
FormMaster Website
Searching snowcovered.com you can certainly find something that can process a payment. That one shouldn't be too difficult.
I'm thinking you may need to sling some code to get the exact experience you are looking for.

Resources