1
b2plane
1y

I cant wrap my head around designing a database system from scratch. Period.

I use ER diagrams to do it. But still i can't figure this piece of shit out.

It usually goes in these steps:

1) i design a very simple minimal system, turns out it works but HELL NO how unsalable it is. Literally its so statically built that i have to redesign the whole infrastructure and models from scratch

2) i redesign from scratch but this time i overengineer it. Overcomplex as fuck. So complex i get lost easily and have to redesign the whole shit all over again this time copying others similar infrastructure with help of chatgpt

3) chatgpt of course fucks everything up even more to the point that my shit can't compile anymore. Fuck this shit

I think i lack the correct way of thinking and approaching this. College has taught me bullshit and confused me even more which is why im so fucking lost. Can someone explain me How to think in the correct mentality when designing an ER database system from scratch.

How do i properly design a scalable database infrastructure as ER diagram for a subscription and chatting models, similar to onlyfans infrastructure?

Comments
  • 4
    If/when it gets to onlyfans level of traffic, you'll have enough dosh to pay someone to do it for you.

    Besides that, what to say?

    Keep to normal forms (aim for at least 2NF), and when dealing with scalability, pick consistency or availability. Can't have both.
  • 2
    Then again, bear in mind the level of usage of each entity.

    Logins and credit card updates and charges are not high traffic. You can keep those in a single database without replicas for availability.

    Shit like messages and such can go in another database set up for maximum availability (even if some messages are out of sync, it ain't a big deal)
  • 0
    @CoreFusionX am i supposed to store messages in database? Cause on whatsapp it is stored locally on phone and deleted in database server. Am i supposed to encrypt (hash) message content if i store it on my database?
  • 0
    @CoreFusionX also everyone recommends to use nosql when it comes to socketio storing chat messages. Specifically DynamoDB. Everything else can be used for postgres. Thoughts?
  • 1
    @b2plane

    WhatsApp *does* store *all* messages in database.

    How else do you think it's able to restore your history when you change telephone?

    They keep a local copy for speed, but it's just a cache.

    They can easily move, say, every month, all messages to long term storage, like S3 glacier, because how many people are restoring at once?

    That's the thing.

    Now, if you are seriously asking if you should hash messages for "encryption", I seriously urge you to go study real cryptography before dealing into this.
  • 0
    @CoreFusionX just tell me if i chat message content should be hashed or saved as plaintext in database. Obv not with bcrypt but perhaps some faster cryptography algorithm that I'd have to google to find out
  • 1
    @b2plane

    No.

    I've told you before. (And this is why despite all your rants, you can't or won't try to make it out of your shit country).

    I gave you the hint. Try to Google at least "hashing vs encryption".
  • 2
    Best practice is to encrypt at rest and encrypt in transit.

    Encrypt at rest is in case someone steals the physical hard drive, they don't get the data. This is usually done with full disk encryption

    Encrypted in transit means a man in the middle can't read the messages. This is done with TLS or mTLS if you're really fancy.
  • 2
    @b2plane big tip for designing architecture is to draw it. You can use a fancy app, but pencil and paper is great for quickly iterating.

    Then it's easy to share with peers for validation, and easy to reference when building
Add Comment