Config table

Hello,

I’m making simple restaurant presentation website and from admin panel you can specify work time.
I’ve made table like this:

+-----------+-------------+------+-----+---------+-------+
| Field     | Type        | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| day_from  | varchar(10) | NO   |     | NULL    |       |
| day_to    | varchar(10) | NO   |     | NULL    |       |
| time_from | varchar(10) | NO   |     | NULL    |       |
| time_to   | varchar(10) | NO   |     | NULL    |       |
+-----------+-------------+------+-----+---------+-------+

And now I have problem with updating this table, what should I use as PK? Can someone help me how to design this table?

Best regards,
@marklenon95

What combination could there never be more than one of?

Primary Keys need to be unique. For example, if there could ever only be one row with a specific “day_from” that field could be used as a PK.

If there could ever only be one row with a specific “day_fromand a specific “time_from” together, those two fields could be used as a “composite primary key”.

1 Like

why do you need a PK?

If you do want a PK ‘just in case’, why don’t you just add an ‘id’ field at the beginning of the table with auto-increment?

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.