You should consolidate these database tables.

I have an event calendar application with an sql database behind it, and now I have 3 tables to represent events:

Table 1: Holiday
Columns: ID, Date, Name, Location, CalendarID

Table 2: Vacation
Columns: Id, Date, Name, PersonId, WorkflowStatus

Table 3: Event
Columns: Id, Date, Name, CalendarID

So, I have “general events” that go into the events table and special events like holidays and vacations that go into these separate tables. I discuss combining them into a single table and just columns like location and personid that are empty for common events.

Table 1: Event:
Columns: Id, Date, Name, Location, PersonId, WorkflowStatus

does anyone see strong positive or negative values ​​for each option. Obviously, there will be records in which there are columns that are optionally applied, but they intersect with these three tables.

+3
source share
6 answers

In any case, you will create it, the application will have to cope with the options. In this situation, I recommend that you use a single view in DBM, because the alternative requires a lot of queries.

, , , , . , . .

+2

, . "EventType" , .

, ( ), , , , , . , , (, , , - , ).

+2

Event? , .

alt text

+2

. , , , , (, , , , . , , .)

, , , , , , , - , - . , - , , ? , , ? ? , - , select * . , , ( , ).

. (, , ) , , .

+2

3 UNION ALL , . , , , .

, , . 3 , , , , . , , , /index, .

, ...

create table EventBase (
  Id int PRIMARY KEY,
  Date date,
  Name varchar(50)
)

... , , .

create table holiday (
  Id int PRIMARY KEY,
  EventId int,
  Location varchar(50),
  CalendarId int
)

... , . , , , , , , -, , - .

+1

:

1: EventCommon

: EventCommonID, Date, Name

2: EventOrHoliday

: EventCommonID, CalendarID, isHoliday

3:

: EventCommonID, PersonId, WorkflowStatus

1- > EventCommon .

+1

Source: https://habr.com/ru/post/1762567/


All Articles