laraTom's avatar

Database design for multiple phones

I have the following table

leads

id phone ...

I need to store multiple phones for leads table, and optional set main phone (can be just one)

so if i create new table i can store multiple phones.

phones

id lead_id phone type main ....

or should i add main_phone_id to lead table with relation to phones.

How would you do it? Thanks

0 likes
3 replies
automica's avatar

@laratom wind back a second. What are you planning for your app to do?

are you just trying to store phone numbers for a contact (or lead)?

lead hasMany phones

phone table

id
lead_id
number
phone_type
is_primary 

if you have multiple types, in a table

switch your type field to phone_type_id and create another table called

phone_types

id
name

and set up a hasOne relationship to the phone_type.

laraTom's avatar

Well , idea is to reformat existing database and able to add multiple phones. We have multiple tables like clients, leads, ... with fields phone, phone2 , phone3 ...

Would like to have one table with phones, with relation_type, relation_id, number, type, is_main

Good point on phone types

Please or to participate in this conversation.