Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use separate related rows when one record can have a variable number of values. For a user’s favorite fruits, keep user details in users and store each selected fruit in a user_fruit table. This one-to-many (or many-to-many, when fruits are shared by users) design supports zero, one, or many choices without changing the schema.

Why repeated values usually belong in rows

A column should represent one attribute with one value for a record. A list such as apple,pear,plum puts several independent values into one field. That makes individual filtering, joining, validation, updating, and enforcing uniqueness harder.

Numbered columns such as fruit1, fruit2, and fruit3 have the opposite problem: they impose an arbitrary limit. Adding a fourth or fifth choice requires a schema change, and queries must check every column.

A child or junction table represents the variable cardinality directly: one row per selected value. The 2012 SitePoint discussion recommends this one-to-many approach, and a related DBA Stack Exchange design uses one score row per game period so overtime does not require new columns (SitePoint discussion; DBA Stack Exchange example).

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

A practical schema for favorite fruits

If fruits come from a controlled list, use a lookup table and a relationship table:

CREATE TABLE users (
  user_id bigint PRIMARY KEY,
  name text NOT NULL,
  phone_number text,
  email_address text
);

CREATE TABLE fruit (
  fruit_id bigint PRIMARY KEY,
  name text NOT NULL UNIQUE
);

CREATE TABLE user_fruit (
  user_id bigint NOT NULL REFERENCES users(user_id),
  fruit_id bigint NOT NULL REFERENCES fruit(fruit_id),
  PRIMARY KEY (user_id, fruit_id)
);

A user who likes apples and pears has two rows in user_fruit. A user with no selections has none. The composite primary key prevents the same fruit from being assigned twice to one user.

Query users who like a fruit

SELECT u.user_id, u.name
FROM users AS u
JOIN user_fruit AS uf ON uf.user_id = u.user_id
JOIN fruit AS f ON f.fruit_id = uf.fruit_id
WHERE f.name = 'apple';

List one user’s choices

SELECT f.name
FROM user_fruit AS uf
JOIN fruit AS f ON f.fruit_id = uf.fruit_id
WHERE uf.user_id = 42
ORDER BY f.name;

When separate columns are the right choice

Use columns when the fields are genuinely distinct and stable, not merely repeated instances of the same thing.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
  • Distinct attributes: first_name, middle_name, and last_name have different meanings.
  • Truly fixed domains: Four known quarter scores can be four columns when the application and rules will always use exactly those four periods.
  • Exactly one value: If a user may select only one favorite fruit, a nullable fruit_id column on users is sufficient.

If the number can grow, shrink, or vary by record, model it as rows instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Rows, arrays, and delimited strings compared

Design Best fit Main limitation
Separate columns Distinct or permanently fixed attributes Schema changes and awkward queries when the count changes
Child or junction table Variable-length values that must be searched, joined, validated, or updated Requires joins and additional tables
Array column Database-specific cases where the collection is usually handled as a whole Element constraints and searches depend on DBMS features
Delimited text Rarely appropriate for relational data Ambiguous parsing, escaping, validation, and inefficient element queries

PostgreSQL supports arrays, but its official documentation cautions: “Arrays are not sets; searching for specific array elements can be a sign of database misdesign.” It recommends considering a separate row for each element because searching can be easier and may scale better with many elements (PostgreSQL 18 Arrays documentation). This advice is PostgreSQL-specific; other systems have different collection types and indexing options.

Keys, foreign keys, and duplicate rules

A foreign key from user_fruit.user_id to users.user_id prevents orphaned relationship rows. A foreign key from user_fruit.fruit_id to fruit.fruit_id limits selections to known fruits. PostgreSQL describes foreign keys as requiring matching referenced values, thereby preserving referential integrity (PostgreSQL constraints documentation).

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

The example uses surrogate numeric IDs, but they are not mandatory. A natural key can be appropriate when it is stable, unique, and practical to reference. PostgreSQL’s tutorial, for example, uses a text city name as a primary key and foreign-key target (PostgreSQL foreign-key tutorial).

When the relationship has more information

Add relationship-specific columns when needed:

preference_order integer,
added_at timestamptz NOT NULL DEFAULT now()

Then make the uniqueness rule match the business meaning. For one row per user and fruit, (user_id, fruit_id) remains the key. If the same fruit may appear in separate dated records, include the relevant date or event identifier instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Index for the searches you actually perform

The primary key (user_id, fruit_id) efficiently supports listing fruits for a user because user_id is first. To find users by fruit, add an index beginning with fruit_id:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
CREATE INDEX user_fruit_fruit_id_user_id_idx
  ON user_fruit (fruit_id, user_id);

In PostgreSQL, declaring a foreign key does not automatically create an index on the referencing columns. Add indexes where query plans and workload show they help; the constraints documentation specifically notes the usefulness of indexing foreign-key columns (PostgreSQL constraints documentation).

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Lookup tables and postal codes

A lookup table is valuable when it enforces an allowed vocabulary, stores metadata, or supplies stable references for a form. It is not required solely because a value appears more than once. For postal or ZIP codes, store the code as text so leading zeroes are preserved and arithmetic is not implied.

Whether to create a postal-code table depends on the quality, licensing, geographic coverage, and update schedule of the dataset you need. Postal codes do not universally map one-to-one to a city, so avoid treating a code as an unquestionable city identifier.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Does five million relationship rows require partitioning?

No universal row-count threshold establishes that partitioning is required—or unnecessary. Five million is a hypothetical from the original forum question, not a benchmark. Partitioning decisions depend on the DBMS, row width, write rate, access patterns, hardware, maintenance goals, and query plans.

  1. Define the important queries and writes.
  2. Create keys and indexes that match those access paths.
  3. Run representative workloads and inspect execution plans.
  4. Consider partitioning only when measured maintenance, pruning, archival, or concurrency requirements justify its added complexity.

Start with a normalized relationship table and evidence from your workload rather than a guessed cutoff.

Decision checklist

  • Are these distinct attributes or repeated instances of one attribute?
  • Can the number of values vary by record?
  • Must users filter, join, validate, report, or update individual values?
  • Are duplicate memberships allowed?
  • Does the target DBMS provide suitable array operators and indexes for this access pattern?
  • Which columns will your real queries use for joins and filtering?

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.