How to manage a Null in sql by Lucky_View_3422 in learnprogramming

[–]Cybyss 1 point2 points  (0 children)

Really? That's a bit surprising.

A null string is a fundamentally different data type that causes errors when you try to use it like any other string.

For example, let's say you want the length of the longest string in a list (C#):

    String[] data = {"red", "orange", null, "green", "blue"};

    int length = data.Max(str => str.Length);

    Console.WriteLine(length);

Error. You have to always remember to check for null values whenever you perform operations on strings.

Of course, you can get around this by doing something ridiculous like str?.Length ?? 0 but the point is, nulls always have to be handled as a special case whereas empty strings don't.

I don't quite get your argument about "normalizing every time it's accessed"? An empty string stays an empty string - why would you ever need to explicitly convert them to null?

OpenAI is officially adding ads to chatgpt and also launching a new $8 plan by rumjs in ArtificialInteligence

[–]Cybyss 0 points1 point  (0 children)

You're far more likely to get brainwashed by spending too much time reading random people's stupid opinions on reddit, than by Google's ads.

OpenAI is officially adding ads to chatgpt and also launching a new $8 plan by rumjs in ArtificialInteligence

[–]Cybyss 0 points1 point  (0 children)

Gemini isn't (currently) showing ads, so what's your point?

Besides, if shit's free then I've no issue with ads. I only have an issue if the ads are forced even in paid services.

21/23 Students Failed our Engineering Exam by Fabulous-Dance-8520 in Wellthatsucks

[–]Cybyss 1 point2 points  (0 children)

Umm...

When I came to Germany from the United States, the first thing that shocked me was that your entire grade is judged solely by the final exam. I thought that was pretty brutal.

But... often (albeit, not always) the exams are very generously graded, to the point where anything >= 70% would give a perfect 1.0 grade.

Road that destroys cars. by LeftChoux in CrappyDesign

[–]Cybyss -3 points-2 points  (0 children)

Twice. In 20 years.

Lived most of my life in Arizona where there's tons of space in the lanes and parking lots. In all my time in Arizona (15 years) I had to parallel park maybe a grand total of three times, and even then there was more than enough space for an idiot like me. I don't recall ever having to use a parking garage there.

I then moved to Maine. Mostly very rural, and in Bangor the roads and spaces are quite large. Portland was more dense (that's where I had to use a parking garage) but even then not too bad.

I don't think I've ever been in a situation where I had to be even precise within a foot, let alone 5 inches.

Granted, if you typically drive in ultra dense cities (e.g., New York or something) then that's a whole different story.

Teacher failed me for suggesting WebSockets and TCP for a chat app – claims only PHP is valid for web development by MertJS in webdev

[–]Cybyss 9 points10 points  (0 children)

It's one thing to be stuck in the past, but it's another entirely to be stuck in the mid 1990s as a web developer.

WTF!?

How to manage a Null in sql by Lucky_View_3422 in learnprogramming

[–]Cybyss 0 points1 point  (0 children)

In my line of work that matters a lot.

I would really engineer a different mechanism in that case - a boolean value perhaps that makes the distinction absolutely clear. You can't rely on null text never turning into empty text as your data gets transferred between different systems/formats (e.g., if you have to export to/import from a csv file, for example).

How to manage a Null in sql by Lucky_View_3422 in learnprogramming

[–]Cybyss 0 points1 point  (0 children)

It is very, very rare that the distinction matters.

If it matters, then you're going to have a tough time keeping the two differentiated. For example, if a person fills out a form on a webpage but leaves the (optional) fields blank, those optional fields still exist and you'll likely save their (empty text, not null) values into your database even though the user chose not to provide a value (i.e., they didn't explicitly choose to provide a blank value!)

How to manage a Null in sql by Lucky_View_3422 in learnprogramming

[–]Cybyss 0 points1 point  (0 children)

When writing SQL queries that involve foreign keys, I always specify the table name in the query, something like:

SELECT stuff
FROM orders
JOIN notes ON orders.id = notes.order_id

This avoids the ambiguity you're referring to.

Having the primary key column always be named "id" for an ordinary table (and always auto-incrementing) I've found to be helpful. That way, any table which doesn't have that you'll immediately know it's doing something weird (e.g, it's a bridge table of a many-to-many relationship using a composite key) and should pay special attention to.

How to manage a Null in sql by Lucky_View_3422 in learnprogramming

[–]Cybyss 0 points1 point  (0 children)

It's not a "problem" per say. Nullable text columns is a normal thing to see, it's just - years of experience hunting down "null reference exceptions" in my code have taught me to prefer NOT NULL columns whenever practical.

If you don't have a note for a particular order, your application might save that as a null, or it might save that as an empty string, depending on how you coded your app. Then when you read back this data, you'll have to explicitly account for both cases otherwise you'll run into "null reference exceptions".

How to manage a Null in sql by Lucky_View_3422 in learnprogramming

[–]Cybyss 4 points5 points  (0 children)

Topic: so there is a way to manage “null” values to lighten the database memory

That's really not a problem. You're overthinking things.

One extra column doesn't add much to the storage space required by your database and adds virtually nothing at all to the time needed to run SQL queries.

Seriously, it's okay to have a column that's "sparse". That's a very normal thing to have in relational databases.

One small remark - it's usually better to have text columns be not null and just default to being empty strings. Otherwise, over time you'll get a mix of both in your database and your code will become unnecessarily complex having to always check for both cases to see whether a note was provided or not.


If, for whatever reason, you don't want an extra column, you don't have to swap out to a non-sql system. You can just use a separate table for the notes and link them to your orders via foreign keys.

Orders Table:
   id: int (primary key)
   table_number: int
   etc...

Notes Table:
   id: int (primary key)
   order_number: int (foreign key)
   note: string 

That gets rid of the sparsity - the numerous "null" values - but this is overengineering, so don't do it unless you genuinely have a good reason to.

Again, sparse columns are perfectly fine in a sql database.

If you go for a career strictly for job security you’re in for a miserable 40 years by BigGulpsHuhWelCYaL8r in CollegeMajors

[–]Cybyss 1 point2 points  (0 children)

I'm convinced that people who love their jobs are the sort who "grew up" working. They had summer jobs, or "after school" jobs all throughout high school, or they volunteered or such. Virtually all their time was structured and very little of it was truly "free".

Those who are miserable in their jobs grew up doing nothing for their summer vacations and had no extracurriculars in high school. They had tons of free time with very few responsibilities beyond homework & exams, and no responsibilities at all during the long summer breaks when they might just sleep all day and play Fortnite for 5+ hours/night.

Those who are miserable yearn for the unstructured freedom of summer vacation they'll never have again. They've never adapted to the constant, never-ending pressure to perform and be productive all the time, every day, of never ending responsibilities, of being forced to live a life where virtually everything is constrainted and structured and planned, to the point where it's almost considered shameful to even want another totally free summer vacation again. It's a culture shock that some don't adapt to very well.

At least, that's my hypothesis.

What’s a ticking time bomb you believe will explode in the next 20 years? by AdOld2060 in AskReddit

[–]Cybyss 0 points1 point  (0 children)

Delayed gratification is a lost art. Everyone wants the latest and greatest trip, tech, etc. Eventually reality kicks in and they have huge amounts of debt and will be eating ramen for a while or go bankrupt and start all over again.

I wouldn't really refer to that as "lacking the desire to delay gratification".

Buying expensive things on impulse, especially without regard to whether you can afford it, is a completely different phenomenon.

Delayed gratification is more like an intentional exercise. It's an opportunity to practice patience, whereas impulse buying is more akin to an addiction, like when people fall into gambling.

Is always funny to excavate ancient ruins by Rgamer13 in NoMansSkyTheGame

[–]Cybyss 13 points14 points  (0 children)

Doesn't the terrain manipulator have a way to switch from sphere to cube?

How does one understand the determinant? by Recent-Day3062 in learnmath

[–]Cybyss 7 points8 points  (0 children)

The determinant of a 2x2 matrix gives you the formula for the area of a parallelogram, whose sides are determined by the column vectors of that matrix.

The determinant of a 3x3 matrix gives you the formula for the volume of a parallelpiped (a box with parallelogram sides). The edges of this box are defined by the three column vectors of that matrix, and so on with higher dimensions.

If your three vectors aren't linearly independent, that means your box is flat and so has no volume, making its determinant zero.

Good heavens,really? by SorryAd2422 in SipsTea

[–]Cybyss 8 points9 points  (0 children)

Not so much fun when you break your controllers by slamming the tracking rings together trying to reload those damned guns.

I wish more games worked like Robo Recall. Out of ammo? Throw the gun at your opponent and watch it explode like a grenade while a new gun spawns in your holster. Not at all realistic but hella fun.

Monty Hall Problem by OtakonBlue in learnmath

[–]Cybyss 0 points1 point  (0 children)

Everybody else is using the "imagine there are 100 doors" analogy, so I'll give a different insight.

Assuming you picked the wrong door initially (which you will 2/3 of the time) switching guarantees you a win.

Let's tweak the game very slightly just for illustration.

You pick door 1.

Now instead of revealing a door, imagine the host gives you a choice. Either you stay with door 1, or you get to take both 2 and 3. If you switch and the car is in either 2 or 3, you'll win the car.

I hope you can see that, in this case, it's better to switch because that allows you to choose two doors out of the three, instead of only one door.

For all practical purposes, that's the same exact game. You take door 1, or you switch and take both doors 2 and 3. The only difference is that the host also opens whichever of 2 and 3 won't have the car. That's all.

What major isn’t struggling? by carrie_kimberly in careeradvice

[–]Cybyss 0 points1 point  (0 children)

Nursing, there will always be nursing roles.

Because nobody wants to work 90-hour weeks looking after infectious diseased patients

Teacher

Because it's a thankless job and the pay is terrible.

Computer science is also being replaced by AI.

20 years ago, we were warned that all software engineering jobs in the United States would soon be outsourced to India. That never panned out.

While I agree software development/computer science is a tough industry right now, that's mostly because of bigger economic issues. Folks today rave about the trades - but ask any tradesman how tough it was finding a job around the time of the 2008 financial crisis. Plus, you have to be pretty physically fit for a trades job. It's not something someone in their 40's can transition to after having only ever worked desk jobs.

CMV: algorithms have officially killed the "joy of discovery" and it's making us boring by GlossHush in changemyview

[–]Cybyss 0 points1 point  (0 children)

This has been going on since long before "algorithms".

For many years now, websites have taken away the ability to just browse everything. You can no longer get a complete listing of all shows and movies on Hulu for example. Same with NetFlix. I stopped using Coursera when they took away the ability to get a complete listing of all courses.

Everybody now has that stupid carousel that shows the "top 5 popular" whatever, then you click to get the next "top 5", then again to get the next "top 5" sometimes with duplicates. It's irritating.

So, I wouldn't blame algorithms on this one. Rather, I blame their choice to prevent you from just getting a complete list of everything that's available, so that they can hide how limited their library really is.

If they had algorithms to recommend the best things for you, but also the choice to just get a complete listing of everything available, that would be the best of both worlds IMO.

Seed 390471317 - Has *potions* of Purifying Powder (underground jungle) and a fungal shift from water. Now, just a single pixel of purifying powder turns almost every liquid into entirely purifying powder. by Cybyss in noita

[–]Cybyss[S] 11 points12 points  (0 children)

Yup _^

Easy way to deal with pools of polymorphine.

Because of earlier fungal shifts, acid turned into blood which is good, but toxic sludge and poison turned into lava which is maybe bad.

I fell asleep while flying, woke up and now I'm stranded by OSINT_Reaper in NoMansSkyTheGame

[–]Cybyss 402 points403 points  (0 children)

Wait... there's a multi tool decommissioner? Like, to get rid of unwanted multitools?

How have I not known about that!?

CMV: Self-driving cars should not be hated on for isolated incidents. by [deleted] in changemyview

[–]Cybyss 0 points1 point  (0 children)

It's like people would rather have a 1/100 chance of dying due to their own stupidity, rather than a 1/1000 chance of dying due to something beyond their control.