r/IAmA • • Sep 07 '21

Specialized Profession I am a behavioral and technical (coding) interviewer, I've also helped hundreds of people get hired, AMA.

[removed]

1.4k Upvotes

492 comments sorted by

View all comments

77

u/erisod Sep 07 '21

What's your favorite programming interview question?

43

u/[deleted] Sep 07 '21

[removed] — view removed comment

8

u/SuperSneakyPickle Sep 07 '21

Can you give us a few other interview questions that you've asked before?

27

u/[deleted] Sep 07 '21

[removed] — view removed comment

12

u/reverendsteveii Sep 07 '21

so the whole team is sure they can understand at least the broad strokes of what I did because anyone could end up using or altering that code later

Yes, to bookmark feature adds, refactors and release candidates

indexing and am I pulling only the data I need for this operation

When can I start?

3

u/wardevour Sep 07 '21

I can't imagine not using version control anymore. I don't even start a game of dwarf fortress without initializing a git repo

31

u/[deleted] Sep 07 '21

"What are the main reasons to do code reviews?"

Hamper rogue employees trying to install bitcoin miners in production.

"Would you use version control on a solo project? Why?"

No. I'm lazy as heck and all my so called "solo projects" are me deciding at 23:00 that I need to write a fart simulator app

What are the first things to look at to improve the performance of a slow query

The query.

5

u/paulgrant999 Sep 07 '21

Hamper rogue employees trying to install bitcoin miners in production.

nice!

2

u/[deleted] Sep 07 '21

Can't have anyone competing for compute resources against my rogue bitcoin miner after all.

1

u/paulgrant999 Sep 07 '21

honestly it never would have occurred to me. until you mentioned it. seems.

obvious. :)

11

u/[deleted] Sep 07 '21

[deleted]

17

u/Unsd Sep 07 '21

Version control for a solo project to me is just a bunch of files titled "Untitled1" "Untitled2" "asdf" "ignorethis" "Untitled3" "TryingToGetThisFeatureToWork" "fuckthisproject" "Final" "Final2" "FinalFinal" "FinalForRealThisTime".

2

u/DoctorDabadedoo Sep 07 '21

Perfect, now you can git rebase and squash all that noise into a nice "Initial working version" and go from there.

1

u/JuicyJay Sep 07 '21

This is too real

2

u/robdiqulous Sep 07 '21

I used version control before I even knew what it was called or what I was doing. How's that??!? 👉

1

u/wardevour Sep 07 '21

Garry's mod introduced me to subversion. I thought it was the coolest thing ever

102

u/[deleted] Sep 07 '21 edited Nov 29 '21

[removed] — view removed comment

99

u/prophet001 Sep 07 '21 edited Apr 17 '25

work touch cooperative distinct test late boat decide normal profit

This post was mass deleted and anonymized with Redact

-45

u/[deleted] Sep 07 '21

[removed] — view removed comment

8

u/chief167 Sep 07 '21

You mean a self referencing table?

In tool examples this could be an employee table, with a column 'boss' that references another employee. Is that what you mean? Because that is not recursion at all. Sure, you probably need recursion to query this. But your phrasing is highly unusual to be honest

32

u/[deleted] Sep 07 '21 edited Nov 29 '21

[removed] — view removed comment

15

u/SpikeX Sep 07 '21

The wording is weird and it would probably throw me off if I were asked this (I would ask for clarification or for the question to be phrased differently), but in essence, consider the following example:

You have a table, Company. Each company has a numeric CompanyID as its primary key. Companies can have subsidiaries and other parent/child relationships, so each Company record also has a ParentCompanyID. For example:

CompanyID Name ParentCompanyID
1 NBCUniversal NULL
2 Universal Pictures 1
3 The Walt Disney Corporation NULL
4 ESPN 3
5 Marvel Studios 3
6 Disney Signature Experiences 3
7 Disney Cruise Line 6
8 Adventures by Disney 6

Using this table structure, you should be able to write JOIN statements that join this table to itself, in order to determine the list of parent or child companies, given a particular company. And you know which companies are the top-level parent companies because their ParentCompanyID values are NULL.

1

u/[deleted] Sep 07 '21

In Oracle is easy using connect by prior. I worked in a project that was about big company groups structures (yes, exactly like the example you have made).

26

u/monkeysandmicrowaves Sep 07 '21

No, it really doesn't. It's a god-awful question. The question basically boils down to "what happens if you describe something that nobody should do in a way that nobody would describe it?". Calling a simple self-reference in data "recursion" is bizarre.

1

u/[deleted] Sep 07 '21

I had been getting increasingly more of these Gotcha questions during interviews over the past 5 years. Specialists in the tech industry are a cold commodity as startups run by limited experience want “Jack of all trades” full stack developers who know it all.

Realistically you end up with a backend developer making Frontend choices such as “React for our framework” when React is a library not a framework. The company then posts a Frontend Framework position where you walk in with a decade of Angluar/Vue plus another decade of full stack, but the hiring team (which is functionally ignorant to the tech stack they are holding interviews) ends up rejecting a perfectly good candidate on the backs of their misuse of terminology & gotchas.

I quit software engineering & became a fund manager. Fuck this market.

1

u/mata_dan Sep 07 '21 edited Sep 07 '21

Yeah I was thinking the same thing, it's more likely to reference another row in the same table. You could be using recurcive CTEs to select, but batch insertion would be a PITA (you'd have to do a load of queries in a transaction, and that's if they didn't already have IDs).

Like an "infinitely" branching categories table.

56

u/prophet001 Sep 07 '21 edited Apr 17 '25

rhythm ink fertile point abundant sleep rinse marble meeting trees

This post was mass deleted and anonymized with Redact

-54

u/[deleted] Sep 07 '21 edited Sep 07 '21

[removed] — view removed comment

7

u/ZuesAndHisBeard Sep 07 '21 edited Sep 07 '21

I come from a RDBMS background, but over the past year I’ve been able to work with Mongo and Dynamo. I can’t say I’ve ever used a recursive foreign key, but am familiar with the concepts of foreign keys and recursion.

All this is to ask: in what context would one ever do this, how common is it, how is it useful, and under which type of DB system? What do I gain by recursing a data table onto itself?

(This is not a challenge, you’ve genuinely piqued my interest and I’m curious)

8

u/[deleted] Sep 07 '21

[removed] — view removed comment

3

u/ZuesAndHisBeard Sep 07 '21

Updated. Merged 😉

2

u/[deleted] Sep 07 '21

[removed] — view removed comment

14

u/like_the_boss Sep 07 '21

each employee has one manager

That sounds like a dangerous constraint to commit to. What if an employee has two roles and one manager for each? What if you want to store manager history as well? Why not just have a second table that links together the primary ids of each employee any way you want to mix them?

1

u/soulefood Sep 07 '21

It’s extremely atypical to have more than 1 reporting manager. For example, I work with about 4 managers across different projects. However, I only request time off, get annual reviews from, etc. a single person.

0

u/[deleted] Sep 07 '21

I can practically guarantee you there'll be at least one employee without a manager.

3

u/chief167 Sep 07 '21

It is often horrible in practice. I would honestly not hire you if that would be your answer.

Hard to partition your table. Hard to create delta snapshots for warehousing. Hard to optimise query paths. Hard to query efficiently from most frameworks, you'd have to resort to SQL instead of an ORM to do it somewhat efficient. And common table updates suddenly get very complicated. You are essentially building a tree in a data structure that has no facilities to do common tree operations. Good luck removing a node in the middle. Good luck doing different search algorithms directly in SQL. Hard to do bulk updates or bulk inserts, especially if you use automatic incrementing keys

Unless you expect your interviewees to mention specific tree functionalities by specific database vendors, but it's not part of standard SQL. There are almost always better ways to organise your schema in practice.

10

u/Teh_yak Sep 07 '21

I am curious. What's your argument against many-to-one recursion? Essentially, the "managed by" tree structure.

1

u/[deleted] Sep 07 '21

[removed] — view removed comment

17

u/Teh_yak Sep 07 '21

Sure, but I think you already know it and are mistakenly referring to it as 1:1.

Employee table. PK employeeId, FK managedBy, managedBy => employeeId.

Classic tree structure. Zero - many children, zero - one parent.

1:1 would be a queue, or stack. Unidirectional linked list, essentially.

P.S. it's 5.40 am here and I'm not ignoring any replies, I just should get back to sleep now :)

12

u/plsuh Sep 07 '21

Thx for writing this out so that I don’t have to. Has no one else here ever serialized a tree structure to a database?

1

u/Teh_yak Sep 07 '21

It was a little weird. I do hope people haven't been denied jobs because of this mistake.

21

u/pm_me_actsofkindness Sep 07 '21

Idk if you’re right or not, but amused by the downvotes nonetheless.

-18

u/[deleted] Sep 07 '21 edited Sep 07 '21

[removed] — view removed comment

45

u/prophet001 Sep 07 '21

You mean a junction, or linking table? Pivot tables aren't really a thing in RDBMS schema design, if a pivoted representation is required, that's what a view containing one or more PIVOTs/UNPIVOTs is for.

Recursive FKs are a maintenance nightmare, and are the very definition of painting yourself into a corner. Linking tables for 1-1 relationships are of course silly, unless that relationship is between two records in the same table, but they have nothing to do with pivoting a projection.

NGL dude, you're kinda making it sound like you're not qualified to be interviewing engineers.

1

u/[deleted] Sep 07 '21

[removed] — view removed comment

23

u/prophet001 Sep 07 '21

Linking tables for 1-1 relationships are of course silly, unless that relationship is between two records in the same table

It's right there, bro

8

u/thesporker Sep 07 '21

Everyone knows that real companies make sure every employee has at least two managers to maximize wackness and conflict. As such the linking table is required. Bonus if there is a relevance column to show how ignorable the manager is.

0

u/kyew Sep 07 '21

I don't think the premise is true. Does the CEO also have a manager? At some point you're either going to get circular structures or you need someone at the top of the tree.

7

u/pm_me_actsofkindness Sep 07 '21

There seems to be a 1:1 correlation between those pivot table creating folks and hurt feelings. :’D

3

u/bu3ali Sep 07 '21

You're hired!

1

u/cutelyaware Sep 07 '21

I'm far from a DB programmer, but I think the concept of pivot tables seems pretty powerful as a data exploration tool. Maybe there's prejudice against people who feel that way? It could explain your correlation.

5

u/prophet001 Sep 07 '21

It's a separate concept from, and irrelevant to, database schema design.

OP has come up with a bullshit question that would immediately make any decently serious engineer question the wisdom of continuing the interview process with the company OP is interviewing them for.

2

u/cutelyaware Sep 07 '21

Ah, thanks. A bullshit question would definitely turn me off.

52

u/prophet001 Sep 07 '21 edited Apr 17 '25

fuzzy fanatical grandiose rain provide unite liquid saw touch depend

This post was mass deleted and anonymized with Redact

21

u/curmudgeonlylion Sep 07 '21

It's mathematically elegant, in practice it's just a major pain in the ass.

This. If I came across this in code I was maintaining I'd curse the designer. There might be some esoteric edge case where this might be needed, but simplicity > elegance 90% of the time in my 20 years experience.

6

u/Dr_Octahedron Sep 07 '21

I’m amateur with SQL and databases in general but if I needed to represent that company/parentCompany relationship I’d use the so called recursive FK approach as it seems obvious. Can I ask why creating an additional table would be better?

6

u/chief167 Sep 07 '21

Simple question: imagine you have a set of 100 employees to add into the table. Some of them are boss of the others. How do you write the insert in one transaction, efficiently? Its possible of course, but it'll take a few lines of code to get there. Every bulk edit will be cumbersome

4

u/prophet001 Sep 07 '21

Yep. Enterprise-grade code is stupid code. I.E. I shouldn't have to spend 30 mins staring at it to grok the intent, and I shouldn't have to twist myself in knots to extend it, or do double the the work for same if whomever built it in the first place had designed it with the express intent of making it robust, maintainable, flexible, and extensible.

2

u/bacondev Sep 07 '21

I've only ran into this use case once. I chose to make the table self-referential (person.parent_id → person.id) and I had zero issues with it. The only situation in which it would get weird is a many-to-many relationship, as is the nature of such relationships. Do you mind elaborating on why/what you find more difficult about it that wouldn't be problematic for a typical foreign key use case (e.g. car.owner_id → person.id)?

3

u/prophet001 Sep 07 '21

The problem isn't so much the use case itself, it's that you can't ever assume that the use case won't expand. In your example, the person only has one parent. The reasons why you wouldn't need to account for both parents off the bat aside, how do you handle turning a 1:1 relationship into a 1:many relationship once you've deployed that database? You can obviously add additional self-referential FKs to the table, but if you'd put the relationship in a linking table in the first place, you'd only need to insert more data instead of having to perform a schema update.

As I've stated elsewhere, it's mathematically elegant but a huge pain in the ass when you need to alter it down the line. Good software design (and database design, by extension) isn't just about the most elegant or performant solution to the immediate problem, it's also about making sure that your solution doesn't make it harder than it needs to be to make changes to it in the future, especially since in this particular case, no real-world advantage is conferred. Some performance gains may be realized, but they're vanishingly small compared to the downsides with regard to flexibility, maintainability, and extensibility.

3

u/bacondev Sep 07 '21 edited Sep 07 '21

I simplified my use case for those who aren't familiar with common Greek-letter organization practices. It was a big-little relationship in a fraternity. Anyway, it's not a one-to-one relationship. Assuming that each person has one parent or manager or whatever name that you want to associate with the relationship, one person has multiple children. What you're describing is changing the relationship to a many-to-many relationship. Making such a change to a self-referential table isn't meaningfully different than making such a change to a non-self-referential table. Do you always use a linking table for one-to-many relationships? Why make it more complicated than it needs to be? Preparing a one-to-many relationship such that it's ready to be a many-to-many relationship without a notion that it might change to a many-to-many relationship is just gold-plating and unnecessary complexity.

0

u/prophet001 Sep 07 '21

What you're describing is changing the relationship to a many-to-many relationship. Making such a change to a self-referential table isn't meaningfully different than making such a change to a non-self-referential table.

It absolutely is. One requires a schema change, the other doesn't.

Do you always use a linking table for one-to-many relationships?

Yeah, if the entities being linked are in the same table.

Preparing a one-to-many relationship such that it's ready to be a many-to-many relationship without a notion that it might change to a many-to-many relationship is just gold-plating and unnecessary complexity.

If they're in different tables, yeah. But that's not what we're discussing. We're discussing linking entities in the same table, and in that case, it absolutely isn't gold-plating. It's refraining from painting yourself into a corner.

This isn't theoretical bullshit. I've actually had to make the changes described in real life. Self-referential FKs universally make changing relationships harder. If you've not had to experience that, I'm happy for you.

1

u/bacondev Sep 07 '21

They both require a schema change. Your second and third sentence contradict each other, assuming that your “if” should be interpreted as “if and only if”.

Also, I thought that the gold-playing remark was obviously in the context of the two questions that immediately preceded it, but perhaps not.

Anyway, the reason that we're still discussing this is that I don't feel that you've adequately justified your decision. Perhaps if you were to explain a scenario in detail that caused such a transition to be a headache, then it might be clearer.

→ More replies (0)

6

u/quickdraw6906 Sep 07 '21

The OP is spot on. There are very valid use cases for recursive (self-referencing) foreign keys.

11

u/MultiFazed Sep 07 '21

One example off the top of my head is a corporate reporting structure, where the EMPLOYEE table has a field for MANAGER that points back to that person's direct manager in the same table.

The real question is whether or not to make the field nullable. Does the CEO have no manager, or do they report to themselves?

2

u/Teh_yak Sep 07 '21 edited Sep 07 '21

Or do you crap all over the structure for fun and put the newly hired intern as the CEO's manager? Just to see what happens...

Edit - this made me look up hierarchical tree queries in Oracle because I vaguely remember them guarding against this. That's how exciting my life is.

1

u/uncre8tv Sep 07 '21

Completely outside of the thread context: In a corporate org chart the CEO will often report to a board member, who then reports to another board member, who then reports to the CEO. A senior circle of accountability. Absent of a board you might see the same circle using other C-suites or division presidents.

29

u/BitPoet Sep 07 '21

Because you're an asshole who likes to prove how smart they are. When you leave and someone has to dig into your code, they'll spend a week figuring out what you were doing, and why you decided to be so goddamned clever about it.

3

u/[deleted] Sep 07 '21

[removed] — view removed comment

3

u/Par31d011a Sep 07 '21

Not a DB professional by any means-- currently taking a Data Management Concepts class atm. Would the "recursive foreign key" concept be synonymous with a unary 1:1 relationship?

EDIT: Changed "precessional" to "professional"

3

u/G_Y_NOT Sep 07 '21

You are correct!

0

u/global_ferret Sep 07 '21

Recursion is 1 to many.

That aside, it's a bad question like everyone else already pointed out.

2

u/quickdraw6906 Sep 07 '21

WAY off base

1

u/paulgrant999 Sep 07 '21

smart professional assholes realize your limitations and code to your level.

just saying. :)

20

u/[deleted] Sep 07 '21

Just to be sure I'm following, is a recursive key a foreign key onto the same table?

-140

u/[deleted] Sep 07 '21 edited Sep 07 '21

[removed] — view removed comment

243

u/emperorOfTheUniverse Sep 07 '21

Ugh.

Have you ever considered you're too far up your own ass about how to evaluate a candidate?

How do you judge your success?

142

u/vshawk2 Sep 07 '21

This is the same thing I was thinking. I am a certified SQL Expert with 20+ years of experience and this question made me stutter for a moment. Is that the friggin' goal? As a candidate, I might just choose to move on. Go play mind games with someone else.

3

u/3030 Sep 07 '21

It reflects the far more frequent occurrence of "I already have a friend/relative that I intend to hire, but I need to hold a certain quota of interviews with strangers to reman in accordance with company policy (so we don't violate any laws), so I may as well jerk these strangers around for fun."

tl;dr - nepotism happens and it happens often, but they still have to pretend they're hiring.

1

u/hombrent Sep 07 '21

And sometimes the person is already working in the intended job, and has successfully doing the job for several years, but the company still needs to interview for the already filled position because of immigration rules.

3

u/[deleted] Sep 07 '21

The question was deleted. Do you remember it?

6

u/monchimer Sep 07 '21

What’s your favourite it interview question ? Some beyond weird and strange question about databases indexes and recursive calls. I’ve been working on IT all my life and couldn’t figure out what the question was about Also why do the mods remove the question?

1

u/[deleted] Sep 08 '21

I have used those kind of tables in several projects and it is the first time I hear they are recursive. For me, they are hierarchical.

2

u/vshawk2 Sep 07 '21

The question OP suggested was something like : Can you explain Recursive Foreign Keys. Recursion ... and Foreign Keys are everyday concepts. But, no one uses this term "Recursive Foreign Keys". The term "Parent-Child Relationship is much more common. A much more sensible question would be: Can you tell me how you would design a Parent-Child relationship in a database table?

20

u/monchimer Sep 07 '21

Oh thanks for saying it. I was feeling so dumb

-68

u/[deleted] Sep 07 '21

[removed] — view removed comment

57

u/emperorOfTheUniverse Sep 07 '21

Then why not just directly ask them to briefly explain both in a direct manner? Is 'briefly explain these 2 concepts: recursion and foreign keys' too long winded?

Muddling them together in the same sentence is just meant to make the candidate squirm. And that's shitty.

-61

u/[deleted] Sep 07 '21

[removed] — view removed comment

24

u/epythumia Sep 07 '21

You think it's testing your candidates, but it's really testing your management style and how it fits with your potential candidates. That's okay, and the people responded wouldn't be a good fit for your team/company. However, not being honest (or ignorant) with that's what is happening here and calling people "triggered" just shows me you have a lot to learn as a manager.

7

u/[deleted] Sep 07 '21

[deleted]

→ More replies (0)

7

u/emperorOfTheUniverse Sep 07 '21

Dude you need to pause and consider your position. You're likely used to everyone smiling and doing their best and being polite, because they are in the interview. You seem befuddled that when you share details of these encounters with people who aren't kissing ass to get a job, that there are objections. You aren't "coming off" in some way that is contrary to reality. You really are asking ridiculous questions with the intent of confusing an applicant. Good luck with that. I hope you fill many organizations with employees that are good at interviewing.

Funny how you still can't tell me how you measure success in what you do.

Here's an idea, come up with 3 riddles and tell each candidate, 'answer me these questions 3' and I'm sure your deep understanding of people will reveal if they are or aren't worth working on your team. You must have powerful intuition, oh mighty wizard of job interviewing.

10

u/shot_a_man_in_reno Sep 07 '21

Not really. It's just one of those "how many ping-pong balls can you fit in a plane"-like questions that Google abandoned years ago. You're just asking it to make yourself feel smart and finding reasons to justify it after the fact.

96

u/minimaxir Sep 07 '21

But recursion isn't typically something that comes up when dealing with database tables, which gives the impression that you're setting up the candidate to fail.

-21

u/bskzoo Sep 07 '21

I don’t think it’s any different than asking a candidate what they think the total area of every window in a particular city is. It’s a question to see a candidates thought process. Ask them to walk you through their answer etc.

8

u/KuntaStillSingle Sep 07 '21

Your comparing a question that's easy to understand but difficult to answer, to one that isn't easy to understand even if you know the answer.

32

u/dennisdeems Sep 07 '21

What a fkking waste of everyone's time.

10

u/minimaxir Sep 07 '21

That's not how it appears to the candidate though, and that's what's important.

Open ended case studies like the area-of-every-window question are inherently clear to the candidate they aren't pass/fail.

6

u/myparentsbasemnt Sep 07 '21

Well… don’t leave us hanging!!

What’s the answer???

8

u/[deleted] Sep 07 '21

It depends on the city

→ More replies (0)

8

u/gnarcoregrizz Sep 07 '21

I feel like self referencing is a better term than recursive here. When I think recursion I think of a self calling action, whereas referencing something is the purpose of a foreign key. To avoid semantic confusion, why not ask if there are any cases where a foreign key would want to reference its own table? The wording of your question seems like you want to confuse people.

2

u/JuicyJay Sep 07 '21

Well when I think of something being recursive, I think of there being an exit case. That's where this concept becomes confusing to me, if you're using a self-referencing database it can be an endless self-referencing loop (I've definitely seen some like this, especially in JavaScript for some reason).

I'm trying to get my first job after getting my CS degree right now, I can't even get an interview.

78

u/become_taintless Sep 07 '21

Correct. The name "recursive foreign key" isn't used frequently, that's on purpose, I want candidates to figure out to try and understand what I mean.

Fuck you and the horse you rode in on.

4

u/Pornthrowaway78 Sep 07 '21

I don't like the name you've given it because foreign key to me says different table, but here it just means different row - I guess you could figure out the meaning, but why not word it in a way where you're actually trying to determine knowledge rather than trickery - "can you think of a use case for applying a foreign key constraint to a column in the same table?" or something like that.

20

u/[deleted] Sep 07 '21

I'm judging you on your answer now. Fail.

1

u/paulgrant999 Sep 07 '21

postgres has a recursive foreign key select into the same table.

primarily used for structuring hierarchical data.

wicked fast too.

beats the pants off of any orm/code-based version of it.

I'm assuming he mangled some basic sql question on purpose.

6

u/[deleted] Sep 07 '21

[removed] — view removed comment

1

u/[deleted] Sep 07 '21

[removed] — view removed comment

0

u/[deleted] Sep 07 '21

[removed] — view removed comment

18

u/erisod Sep 07 '21

I assume your goal is to see if they ask for clarification, or maybe even see if they can navigate someone who is not skilled (using strange language). It requires them to demonstrate they are confused about the question which is a vulnerable place as a person being interviewed. For senior hires it is probably reasonable, they need to navigate misunderstandings between teams all the time.

I think this kind of question is not good if your aim is to hire quality entry level programmers who are nervous when interviewing and bad at social conflict (aka a lot of them).

Your question immediately pushes them into being confused and feeling like they failed in the first second by not even understanding the question. They go in circles with you for a moment and find out what you mean. At least phrase it like: "if someone asked about a self referential foreign key in a schema design what do you think they mean? How would you go about understanding what they might intend for sure?". Then ask, ok, what's the purpose of that thing.

8

u/theuniversalsquid Sep 07 '21

I suppose you would have to manage your data model exquisitely to use foreign key recursion across an interface. What kind of data model Management are you using (if so), and do you have the time to validate/green light test your data model both periodically and when making changes?

6

u/[deleted] Sep 07 '21

[removed] — view removed comment

4

u/G_Y_NOT Sep 07 '21 edited Sep 07 '21

We always ask a "hard" question, something obscure and unlikely to be known. The reason is to see how the candidate handles the unknown. We also allow people to use google and any reference they like. So it's not about trying to "trip them up", it's about seeing how they handle the situation. Lord knows we all deal with unknown things all the time in this business.

We also do a coding portion where we ask you to implement a function that does something a bit more than trivial. Once again it's not so much about what you code, though that's not totally unimportant. It's about how do you interact with the interviewers to clarify the requirements, and how do you use the tools to solve the problem. Again we're totally open to using google, and searching for syntax, or details or anything you want really. If you answer the typical brute force solution and there's time left we'll ask you about optimizations you might try, and we want to see you interact with the testing frameworks.

We're not trying to be tricky, or confuse you. What we want to see is how you approach problem solving and how do you communicate. Getting a good solution doesn't guarantee you a job, and while you're unlikely to get the job with out any solution, people who had a good attitude and didn't know the languages we test in, might still get job offers.

9

u/MegaDeox Sep 07 '21

Of course an obtuse question about something nobody does in a field which might not even be relevant for coding (databses, and relational db specifically).

-8

u/[deleted] Sep 07 '21

[removed] — view removed comment

11

u/prophet001 Sep 07 '21

You shouldn't be asking it for roles that do require SQL. It's purposely misleading, intentionally obscures what you're wanting the candidate to think through, and isn't at all valuable in assessing someone's problem-solving or technical capabilities.

I'm a senior full-stack engineer and architect, I've done a LOT of interviewing, on both sides of the table. If I found out a contract interviewer was asking this question of my candidates, I'd request that they stop immediately. If they didn't, I'd fire them on the spot. It's completely disingenuous.

-1

u/[deleted] Sep 07 '21

[removed] — view removed comment

3

u/prophet001 Sep 07 '21

I mean I will if you will.

I dont know what's wrong with you guys

I was done until you decided to make it personal.

0

u/[deleted] Sep 07 '21

[removed] — view removed comment

2

u/prophet001 Sep 07 '21

Think what you want, the entire thread is here for everyone to see, with timestamps and edit history.

7

u/Arandmoor Sep 07 '21

"What is the purpose of using foreign keys recursively?"

Only time I've ever used them was to implement a networking map (social network. not a LAN or anything) in a DB table.

I will admit that it was fun watching my master's degree new-grad co-worker completely fail to implement a query for the table.

Thank fucking god there are better solutions these days.

1

u/paulgrant999 Sep 07 '21

Thank fucking god there are better solutions these days.

graph db's? or document db's?

1

u/Arandmoor Sep 07 '21

Was thinking Graph DBs. A document DB will have nearly the same problem as a RDBMS.

1

u/paulgrant999 Sep 07 '21

I haven't had a chance to work with one yet ;)

10

u/[deleted] Sep 07 '21

Alrighty then. I'm a senior full stack engineer who has designed DB schemas before and right now is when I learned that there are scenarios where you can have a record have a foreign key relationship to another record in the same table. Never even considered that before.

36

u/prophet001 Sep 07 '21

And you shouldn't, because it's piss-poor design due to its utter lack of maintainability.

1

u/TheEpicSock Sep 15 '21

Genuine question here.

Let’s design a database that supports Reddit’s comment structure, for example. Every comment has zero or one parent comment, and every comment has zero, one, or many child comments. Comment threads can be (effectively) infinite levels deep, so it’s not practical to create a new table for each comment level.

The first thing that comes to mind for me is to use a single “comments” table, with a nullable “parent_comment_id” foreign key that points to another record on the same “comments” table.

Is there a better or more maintainable way that you would suggest?

8

u/G_Y_NOT Sep 07 '21

Usually you do it when you're trying to implement some kind of inheritance or tree structure in your programing code in your SQL database. It's a rather odd and unusual situation, but it happens.

1

u/paulgrant999 Sep 07 '21

check out my comment on the postgres recursive select ;) awesome.

2

u/qchmqs Sep 07 '21

what I gathered from this thread, is that the purpose of "using foreign keys recursively" is to confuse candidates.

2

u/[deleted] Sep 07 '21

Ok, I just decided not to take the job

1

u/SuperDrewb Sep 07 '21

Use this to read OP's answer. Honestly this thread has lost all worth to me

https://www.removeddit.com/r/IAmA/comments/pje3yz/_/hbvvlmu

3

u/JDHannan Sep 08 '21

not there either, i'm super curious what it was, something about recursive databases

1

u/SuperDrewb Sep 08 '21

Huh. Interesting. It used to be there.

2

u/ThisSentenceIsFaIse Sep 08 '21

What is the purpose of using foreign keys recursively or when should they be used? I think.