Database / Google Spanner Database Interview questions
Define interleaved tables in Google Spanner?
An interleaved table is a child table whose rows are physically stored next to the parent row they belong to, based on a shared primary key prefix. You declare the relationship with INTERLEAVE IN PARENT, and the child's primary key must start with the parent's primary key columns.
CREATE TABLE Orders ( CustomerId INT64 NOT NULL, OrderId INT64 NOT NULL, OrderDate DATE ) PRIMARY KEY (CustomerId, OrderId), INTERLEAVE IN PARENT Customers ON DELETE CASCADE;
Because parent and child rows sit in the same storage split, fetching a customer and their orders together avoids extra network hops, which is far cheaper than a traditional join across separately sharded tables. It also lets Spanner co-locate related data as it splits and moves ranges for load balancing.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
