<FromGitter>
<bew> If you need it, I think you can reopen the discussion about it by making an issue on github
<FromGitter>
<bew> @drum445 ☝️ (@j8r)
<FromGitter>
<j8r> Oh... I remember this discussion, thanks for the reference @bew
DmitryBochkarev_ has joined #crystal-lang
<FromGitter>
<drum445> can't find a quick way to grab the latest file
<FromGitter>
<drum445> dir could have 10ks
ua has quit [Excess Flood]
DTZUZO has joined #crystal-lang
ua has joined #crystal-lang
<FromGitter>
<j8r> after appending ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ to `String`, I got `Error opening file '/app/s/r/c/c/o/m/p/i/l/e/r/c/r/y/s/t/a/l/c/r' with mode 'r': No such file or directory (Errno) ... [https://gitter.im/crystal-lang/crystal?at=5ca627b693fb4a7dc2d32132]
<FromGitter>
<silmanduin66> hello i need help with databases . I m using granite and it s working so far for my small chat app with just one chat group . My database has a table which stores messages. Now i want to expand my app and let user create group chat. My question: how should i model that ? Can i just let users create / remove tables in my database? How do people usually programmate that?
<FromGitter>
<j8r> users have specific rights on specific tables
<FromGitter>
<j8r> and usually that's the app that deal with use permissions
<FromGitter>
<j8r> usually the interactions are done through an API
<FromGitter>
<silmanduin66> giving rights to specifc users is actually not a concern for me i can do that, the problem was that i saw on some forums people saying : "tables are used to defines types and rows are used to stores instances"
<FromGitter>
<j8r> maybe, I don't SQL. What can I say is better having a safe API that is database agnostic
<FromGitter>
<tenebrousedge> tables = types and rows = instances is probably a reasonable analogy
<FromGitter>
<tenebrousedge> probably a good start would be to have a "Groups" table
<FromGitter>
<tenebrousedge> messages could have a "group_id", which would be a foreign key reference to the `groups` table
<FromGitter>
<tenebrousedge> this is just a personal project, right? @silmanduin66
<FromGitter>
<silmanduin66> yes it s my project
<FromGitter>
<silmanduin66> but if i have 100 groups and 1 million messages it would be hard to manage right ? ( it won t happen but i try to understand the theory )
<FromGitter>
<tenebrousedge> a million rows isn't "lots" for a database, but yes, with bigger numbers you would have lots of performance issues
<FromGitter>
<silmanduin66> or should i create a database for each group ?
<FromGitter>
<tenebrousedge> it's not really a good idea to design an app for a scale it won't operate on. Usually you can't plan that far ahead. The problems of the app with 100 users are not the same kind of problems as the app with 100M users. A full-scale chat app would probably want to look into distributing large chunks of the db to different geographical locations, because users will tend to be in the same place most of the
<FromGitter>
... time
<FromGitter>
<tenebrousedge> but, if you design a good API, your chat client and most of the rest of the code won't have to care how your database servers are arranged
<FromGitter>
<silmanduin66> hmm i get the idea that it should depend on the size of the product , but i still don t understand the theory behind thoses models. I have the same problem about a game that lets users create / remove countries ( in a fiction world ) and each country has a list of cities.
<FromGitter>
<Blacksmoke16> prob could have a group table, that holds data about that, then a table that matches users to a group
<FromGitter>
<silmanduin66> i m stuck at the same point
<FromGitter>
<Blacksmoke16> where messages table would have `group_id` column that is either the group that message is from, or null if its not part of a group message?
<FromGitter>
<Blacksmoke16> would need a mapping table since it would be many to many
<FromGitter>
<silmanduin66> i think that it should work, but what if there are millions of message, and i want to get all the messages of 1 single group, i dont want to loop through all messages right ?
<FromGitter>
<Blacksmoke16> thats what the `group_id` column would be for
<FromGitter>
<tenebrousedge> you would want an index on the group_id column for best performance
<FromGitter>
<Blacksmoke16> would do like `group.messages` which would be like `SELECT * from messages where group_id = ?`
<FromGitter>
<Blacksmoke16> would be a FK so would have one inherently
<FromGitter>
<tenebrousedge> the db may do that automatically for a foreign key index
<FromGitter>
<Blacksmoke16> ey
<FromGitter>
<silmanduin66> ok , so in this model i can keep all messages in a single table ?
<FromGitter>
<Blacksmoke16> yes
<FromGitter>
<tenebrousedge> for a while :)
<FromGitter>
<silmanduin66> ok ill try that :-D
<FromGitter>
<Blacksmoke16> i mean eventually you could prob use like hadoop or something maybe?
<FromGitter>
<Blacksmoke16> sounds good
DmitryBochkarev_ has quit [Ping timeout: 255 seconds]
<FromGitter>
<Blacksmoke16> it really helped me make a better DB, much easier to maintain
<FromGitter>
<silmanduin66> i have actually no idea about all that but i m willing to learn so why not but later :-D
<FromGitter>
<Blacksmoke16> well if you're redoing your DB anyway it would be helpful to keep that in mind
DmitryBochkarev_ has joined #crystal-lang
DmitryBochkarev_ has quit [Max SendQ exceeded]
<FromGitter>
<Blacksmoke16> the main jist of it is to move data to other tables so that it is only defined in one place in one row, then everything else that uses it, just uses the reference to that one other row
<FromGitter>
<Blacksmoke16> granted, it also depends on use cases of what makes sense/how far to go. but is worth understanding
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter>
<Blacksmoke16> np, feel free to ask any questions ofc
sz0 has quit [Quit: Connection closed for inactivity]
rohitpaulk has quit [Remote host closed the connection]
Jenz has quit [Quit: Lost terminal]
Jenz has joined #crystal-lang
Jenz has quit [Ping timeout: 245 seconds]
lucasb has joined #crystal-lang
olbat has quit [Quit: Bye ...]
hightower2 has joined #crystal-lang
olbat has joined #crystal-lang
<hightower2>
hi olbat
<olbat>
hi :)
<FromGitter>
<ryanstout> @<Jenz> I've been working on a ruby extension using ruby-ffi and ```fun``` in the global scope in crystal
<FromGitter>
<ryanstout> works pretty well
<FromGitter>
<ryanstout> I was thinking of using crystal macros to automatically create a file for the ffi code on the ruby side. (and maybe releasing that as a shard)
<FromGitter>
<ryanstout> I know there were a few projects to do ruby<->crystal integration, but none of them seemed to be active or that far along