I want to store data on various engines in a MySQL database, which includes both piston and rotary engines.
In OO languages, I can create and extend an Engine
superclass to obtain PistonEngine
and RotaryEngine
subclasses.
The PistonEngine
subclass would contain properties such as CylinderNo, PistonBore and PistonStroke.
The RotaryEngine
subclass would contain properties like RotorThickness and RotorDiameter.
In MySQL, while I can create two separate tables for piston and rotary engines respectively, I would prefer to maintain an EngineType field as part of the engine data, and store all data common to both engine types in a single table.
How can I design my database to avoid data redundancy as much as possible?