Tutte le specialitàTecnologia · Colloquio di lavoro

Database

Le domande sui database uniscono teoria e incidenti reali. Preparati a spiegare sia come funziona qualcosa sia come hai trovato una query lenta in produzione.

Parole → espressioni → frasi → parlato

Prova SpeakRole ↗
Colloquio di lavoroDatabase
V

When would you choose a relational database over a document store?

0:18
Domanda dell’intervistatore

Database

I colloqui sui database di solito vanno dalle basi (SQL, join, indici) alle transazioni e alle prestazioni. Nella parte orale la competenza chiave è spiegare un'idea tecnica in modo semplice, senza disegnarla alla lavagna.

Usa il contrasto per rendere chiare le risposte: «con un indice il database fa X; senza, fa Y». Il contrasto è facile da ricordare per chi ascolta e facile da dire in inglese.

  • ✓Parole → espressioni → frasi → parlato
  • ✓Senso della risposta
  • ✓Lingua

Domande comuni e risposte di esempio

When would you choose a relational database over a document store?

Quando sceglieresti un database relazionale invece di un document store?

Che cosa vuole sentire l'intervistatore. Criteri concreti e la consapevolezza che molti sistemi usano entrambi.

Risposta di esempio in inglese da esercitare ad alta voce

I choose a relational database when the data has a clear structure and relationships, and when I need strong consistency and transactions, for example orders and payments. SQL also gives me flexible queries, joins and constraints that protect the data. A document store is a good choice when the data is naturally one nested document, the schema changes often, or I need to scale writes horizontally and I can accept simpler queries. In many projects I use both: a relational database as the source of truth and a document store or a search engine for specific reads.

How does an index work, and what does it cost?

Come funziona un indice e quanto costa?

Che cosa vuole sentire l'intervistatore. La struttura, il vantaggio, il costo in scrittura e l'ordine delle colonne negli indici composti.

Risposta di esempio in inglese da esercitare ad alta voce

An index is an additional data structure, usually a B-tree, that lets the database find rows without scanning the whole table. It is like the index at the back of a book. It speeds up reads, sorting and joins, but it costs disk space and slows down writes, because every insert and update must also update the index. For a composite index, the order of columns matters, because the database can use only the leftmost part. I create indexes for the real queries, check them with EXPLAIN and remove the ones that are not used.

What does ACID mean?

Che cosa significa ACID?

Che cosa vuole sentire l'intervistatore. Quattro proprietà spiegate con un unico esempio.

Risposta di esempio in inglese da esercitare ad alta voce

ACID describes the guarantees of a transaction. Atomicity means that a transaction is all or nothing. Consistency means that it moves the database from one valid state to another, so constraints are respected. Isolation means that concurrent transactions do not see each other's unfinished work, to the degree defined by the isolation level. Durability means that once a transaction is committed, it survives a crash, usually because it is written to a log on disk. A classic example is a money transfer: both the withdrawal and the deposit happen, or neither does.

A query is slow in production. What do you do?

Una query è lenta in produzione. Che cosa fai?

Che cosa vuole sentire l'intervistatore. Un metodo: misurare, leggere il piano, correggere, verificare.

Risposta di esempio in inglese da esercitare ad alta voce

First I measure, I do not guess. I find the exact query, from the slow query log or monitoring, and run EXPLAIN to see the plan. I look for a full table scan, a missing or unused index, a bad join order or outdated statistics. Often the fix is a better index or a rewritten query. In applications with an ORM, I also check for the N+1 problem, where one request creates hundreds of small queries. After the change, I compare timings with real data volumes, because a query can be fast on a small test database and slow in production.

What are isolation levels, and what problems do they prevent?

Che cosa sono i livelli di isolamento e quali problemi evitano?

Che cosa vuole sentire l'intervistatore. Dirty read, non-repeatable read e phantom, e il compromesso con la concorrenza.

Risposta di esempio in inglese da esercitare ad alta voce

Isolation levels control what a transaction can see from other concurrent transactions. Read committed prevents dirty reads, so you see only committed data. Repeatable read also prevents non-repeatable reads: the same row gives the same value inside one transaction. Serializable also prevents phantom reads, where a repeated query returns new rows, and it behaves as if the transactions ran one by one. Higher levels give more safety but lower concurrency. Many databases, such as PostgreSQL, use read committed by default, and I raise the level only for operations where the anomaly would be a real business problem.

Come pronunciare i termini chiave

SQL
es-chiu-èl oppure «sì-quel»
schema
schì-ma
query
cuì-ri
ACID
ès-sid
normalisation
nor-ma-lai-zèi-shon
transaction
tran-zàc-shon

Frasi utili per rispondere

  • The database has to scan the whole table.Il database deve scansionare l'intera tabella.
  • It trades read speed for write cost.Si scambia velocità di lettura con un costo in scrittura.
  • I would look at the execution plan first.Guarderei prima il piano di esecuzione.
  • That query uses an index, so it is fast.Quella query usa un indice, quindi è veloce.
  • In our system, the source of truth is…Nel nostro sistema, la fonte di verità è…
  • I would measure before I optimise.Misurerei prima di ottimizzare.

Errori comuni da evitare

  • Dire «NoSQL è più veloce». Più veloce per cosa? Indica il pattern di accesso.
  • Aggiungere indici ovunque. Cita il costo in scrittura e il fatto che controlli il piano.
  • Confondere la C di ACID (regole di validità dei dati) con la C del teorema CAP (coerenza tra i nodi). Di' quale intendi.
  • Non dire come hai verificato una correzione. Cita il piano, i tempi e il volume dei dati.

Domande frequenti

Quanto SQL dovrò scrivere in un colloquio?

Spesso una query breve su uno schermo condiviso o su carta: una join, una group by, a volte una window function. Di' il piano prima di scrivere: "First I join orders to customers, then I group by month."

Quale database devo dire di conoscere meglio?

Quello che hai usato davvero. PostgreSQL e MySQL sono i più diffusi, e devi dire come li hai usati: progettazione dello schema, tuning e migrazioni.

Devo conoscere il funzionamento interno dei database?

Per la maggior parte dei ruoli basta un quadro semplice: indici B-tree, il write-ahead log e come le transazioni si isolano a vicenda. Una conoscenza più profonda conta per i ruoli su database o su piattaforme dati.

Leggere una risposta non è la stessa cosa che dirla. Esercita ogni domanda ad alta voce, poi confronta il significato e la lingua della tua risposta.

Prova SpeakRole ↗

Altri argomenti in quest’area