I am an beginner-to-intermediate level programmer and am trying to re-design a MySQL database for someone. It has the following attributes:
- Shows start and end times for alcohol sales in an area
- Times vary by day of week
- Times vary for beer and wine vs. all types of alcohol (liquor, too).
- Times vary by off-premises (i.e.: liquor store) vs. on-premises (i.e.: bar)
I tried researching this but couldn't find a clear answer. Currently he one huge table. Example columns are:
- offwedbwstart (off-premises, Wednesday, beer & wine only, starting time)
- onfriallend (on-premises, Friday, all alcohol types, end time)
I'm wondering if there isn't a better way to organize this table using arrays as entries or by using multiple tables. Does anyone have any ideas? Or is this simply a matter of preference? I'm also worried about the efficiency of using multiple tables.
Thank you!
Revision in response to comment (more detailed explanation):
Here's are the fields of the original table which I'm tasked with revising. It is all one big table:
id
BIGINT(9) NOT NULL, - Primary Key
state
TINYTEXT NULL, -
Full State Name
county
TINYTEXT NULL, - Full County Name
place
TINYTEXT NULL, - Full Place Name
placetype
TINYINT(2)
NULL DEFAULT NULL, - Is the Place a County, City, etc.
format
TINYINT(1) NULL DEFAULT NULL, - Not sure
multname
TINYINT(1)
NULL DEFAULT NULL, - Does the place have multiple names
multcounty
TINYINT(1) NULL DEFAULT NULL, - Does the place cross
multiple counties
population
INT(8) NULL DEFAULT NULL, -
Population
offsunallstart
SMALLINT(4) NULL DEFAULT NULL, -
Off-Premsies (convenience stores, liquor stores, etc.), Sunday, All
types of alcohol (including liquor), Start Time (military time
integer, hours and minutes past midnight)
offsunallend
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises, Sunday, All types of
alcohol, End Time (military time integer, hours and minutes past
midnight)
offsunbwstart
SMALLINT(4) NULL DEFAULT NULL, -
Off-Premises, Sunday, Beer and Wine only,Start Time
offsunbwend
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises, Sunday, Beer and Wine
only,End Time
offmonallstart
SMALLINT(4) NULL DEFAULT NULL, -
Off-Premises, Monday, All types of alcohol, Start Time
offmonallend
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises, Monday,
All types of alcohol, End Time
offmonbwstart
SMALLINT(4) NULL
DEFAULT NULL, - Off-Premises, Monday, Beer and Wine only,Start
Time
offmonbwend
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises,
Monday, Beer and Wine only,End Time
offtueallstart
SMALLINT(4)
NULL DEFAULT NULL, - Off-Premises, Tuesday, All types of alcohol,
Start Time
offtueallend
SMALLINT(4) NULL DEFAULT NULL, -
Off-Premises, Tuesday, All types of alcohol, End Time
offtuebwstart
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises,
Tuesday, Beer and Wine only,Start Time
offtuebwend
SMALLINT(4)
NULL DEFAULT NULL, - Off-Premises, Tuesday, Beer and Wine only,End
Time
offwedallstart
SMALLINT(4) NULL DEFAULT NULL, -
Off-Premises, Wednesday, All types of alcohol, Start Time
offwedallend
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises,
Wednesday, All types of alcohol, End Time
offwedbwstart
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises, Wednesday, Beer and
Wine only,Start Time
offwedbwend
SMALLINT(4) NULL DEFAULT NULL,
- Off-Premises, Wednesday, Beer and Wine only,End Time
offthuallstart
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises,
Thursday, All types of alcohol, Start Time
offthuallend
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises, Thursday, All types of
alcohol, End Time
offthubwstart
SMALLINT(4) NULL DEFAULT NULL,
- Off-Premises, Thursday, Beer and Wine only,Start Time
offthubwend
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises,
Thursday, Beer and Wine only,End Time
offfriallstart
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises, Friday, All types of
alcohol, Start Time
offfriallend
SMALLINT(4) NULL DEFAULT NULL,
- Off-Premises, Friday, All types of alcohol, End Time
offfribwstart
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises,
Friday, Beer and Wine only,Start Time
offfribwend
SMALLINT(4)
NULL DEFAULT NULL, - Off-Premises, Friday, Beer and Wine only,End
Time
offsatallstart
SMALLINT(4) NULL DEFAULT NULL, -
Off-Premises, Saturday, All types of alcohol, Start Time
offsatallend
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises,
Saturday, All types of alcohol, End Time
offsatbwstart
SMALLINT(4) NULL DEFAULT NULL, - Off-Premises, Saturday, Beer and
Wine only,Start Time
offsatbwend
SMALLINT(4) NULL DEFAULT NULL,
- Off-Premises, Saturday, Beer and Wine only,End Time
onsunallstart
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies (bars,
restaraunts, etc.), Sunday, All types of alcohol, Start Time
onsunallend
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies, Sunday,
All types of alcohol, End Time
onsunbwstart
SMALLINT(4) NULL
DEFAULT NULL, - On-Premsies, Sunday, Beer and Wine only,Start
Time
onsunbwend
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies,
Sunday, Beer and Wine only,End Time
onmonallstart
SMALLINT(4)
NULL DEFAULT NULL, - On-Premsies, Monday, All types of alcohol, Start
Time
onmonallend
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies,
Monday, All types of alcohol, End Time
onmonbwstart
SMALLINT(4)
NULL DEFAULT NULL, - On-Premsies, Monday, Beer and Wine only,Start
Time
onmonbwend
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies,
Monday, Beer and Wine only,End Time
ontueallstart
SMALLINT(4)
NULL DEFAULT NULL, - On-Premsies, Tuesday, All types of alcohol,
Start Time
ontueallend
SMALLINT(4) NULL DEFAULT NULL, -
On-Premsies, Tuesday, All types of alcohol, End Time
ontuebwstart
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies, Tuesday,
Beer and Wine only,Start Time
ontuebwend
SMALLINT(4) NULL
DEFAULT NULL, - On-Premsies, Tuesday, Beer and Wine only,End Time
onwedallstart
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies,
Wednesday, All types of alcohol, Start Time
onwedallend
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies, Wednesday, All types of
alcohol, End Time
onwedbwstart
SMALLINT(4) NULL DEFAULT NULL, -
On-Premsies, Wednesday, Beer and Wine only,Start Time
onwedbwend
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies, Wednesday,
Beer and Wine only,End Time
onthuallstart
SMALLINT(4) NULL
DEFAULT NULL, - On-Premsies, Thursday, All types of alcohol, Start
Time
onthuallend
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies,
Thursday, All types of alcohol, End Time
onthubwstart
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies, Thursday, Beer and Wine
only,Start Time
onthubwend
SMALLINT(4) NULL DEFAULT NULL, -
On-Premsies, Thursday, Beer and Wine only,End Time
onfriallstart
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies, Friday,
All types of alcohol, Start Time
onfriallend
SMALLINT(4) NULL
DEFAULT NULL, - On-Premsies, Friday, All types of alcohol, End
Time
onfribwstart
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies,
Friday, Beer and Wine only,Start Time
onfribwend
SMALLINT(4)
NULL DEFAULT NULL, - On-Premsies, Friday, Beer and Wine only,End
Time
onsatallstart
SMALLINT(4) NULL DEFAULT NULL, -
On-Premsies, Saturday, All types of alcohol, Start Time
onsatallend
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies, Saturday,
All types of alcohol, End Time
onsatbwstart
SMALLINT(4) NULL
DEFAULT NULL, - On-Premsies, Saturday, Beer and Wine only,Start
Time
onsatbwend
SMALLINT(4) NULL DEFAULT NULL, - On-Premsies,
Saturday, Beer and Wine only,End Time
offexceptions
TEXT NULL,
- Off-Premises exceptions as a note
onexceptions
TEXT NULL, - On-Premises exceptions as a not
source
TEXT NULL, - Where did
this information come from?
sourcelink
TINYTEXT NULL, - Link
for information
timezone
TINYTEXT NULL, - TimeZone (EST, for
example)
notes
TEXT NULL - Other miscellaneous notes
As you can see this is kind of a data nightmare. I've been reading up on how to organize this better and some problems that come up are crossing over midnight for sales, and there is another problem of multiple days of the week having the same start and close times, to which I thought I could create a table that simply had the fields:
- Start Day (weekday, integer representation)
- End Day (weekday, integer representation)
- Start Time (hours past midnight that morning, integer representation)
- End Time (hours past midnight that morning, integer representation)
Please feel free to make any suggestions for a schema.
Thank you!