Gerard Ram

Greenhorn
+ Follow
since Aug 29, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gerard Ram

I'm trying to build my app database and I'm new to the DB world, so I have doubts about my ER model and it's relationships.

This is an app that connects to an API from Strava to check your bike workouts and track the life (durability) of your bike components depending on the Kilometers you have traveled.

The information I want to save is the Users and their Bikes (Only one, but maybe I'll permit more than 1 bike).

From Users, I want to store:
> ID
> Name
> Surname

And from Bikes, I need to know if the bike is a Mountain Bike, if it has tubeless tires and if it's single chainring.
> ID
> isSingleChainRing
> isTubeless
> isMTB

Also, the bike have diferent components, so I created a table for them (Chain, tyres, etc...). I need to know when was the last time the user set that component value to 0 (imagine the user replaces the chain, so he can reset to 0KM again.)
> ID
> component name
> last_reset

So I've thought in this ER diagram, but I don't know if the relationship between the tables Bike and Components should be n:m instead of 1:N. As I understand it, a Bike, can have a lot of components, but a component can only be of 1 bike. Or if the components tables has fixed values, each component can be assigned to a lot of bikes as well?

If the correct relationship is n:m should I create a linking table? I heared you need an extra table to link that n:m relationships.


https://imgur.com/a/JCeRrZG

Thanks for your help.