I have 2 kinds of units that can be leased, trucks and heavy equipments. Each of them has it's own attributes, so i create 2 tables for them.

Then i have Order_Details table which stores the Order key and the unit key.

I'm confused as how to connect the trucks and heavy equipments table with the Order_Details table. I really want to use one ID for both kinds of units. Or do i need to have two Order_Details tables each for the truck and the heavy equipment? Or maybe there are better solutions?

Thx in advance.

I would probably create a single table for Units and give a unique ID to each truck and equipment. The ID would be a SKU built from a pre-defined set of rules describing how it's formed. For example, every truck ID would be prefixed with a T, and equipment could all begin with E. This would simplify your orderDetails table because then you could reference a single ID regardless of the type of Unit being leased. I would likely use a separate table then to store Unit attributes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.