13Databases

With the rise of web-based applications, more programmers use databases for data storage and manipulation, so don’t be surprised if you are asked questions about your experience with databases, and asked to solve some database problems

DATABASE FUNDAMENTALS

Tools are available to help you create and manage databases, many of which hide the complexities of the underlying data structures. Ruby on Rails, for example, abstracts all database access and makes most direct access unnecessary, as do component technologies such as Enterprise JavaBeans and many object-oriented frameworks. Still, you need an understanding of how databases work to make good design decisions.

Relational Databases

Data in a relational database is stored in tables, which consist of rows and columns (also known as tuples and attributes). A set of table definitions is referred to as a schema. Each column has a name and data type associated with it. The column data type limits the range of data that can be stored in the column; the column may also have additional constraints beyond those imposed by the type. Typically, the columns of a table are defined when the database is created; columns are modified infrequently (or never). Data is added and removed from a table by inserting and deleting rows. Although the columns are typically ordered, the rows aren’t. If ordering of rows is required, it is done when the data is fetched (via a query) from the database.

Most tables have keys. A key is a column ...

Get Programming Interviews Exposed, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.