About Table Design

Asked 2 years ago, Updated 2 years ago, 98 views

I'm working on a table design, but I'm having a hard time with my first training, so I'd like some advice.

I won't give you any specific information, so it's an example.
Assume Table

There is a table like the one above, but every time the content of the incident increases, the details I want change, so the columns increase.

What is required is to know the list of events in chronological order and the details of each case.What kind of measures can you think of?Thank you for your advice.

sql database sql-server

2022-09-30 14:56

4 Answers

"The details you want will change," but a table that changes the contents will not make the database consistent.

I understand that it is not clear how to organize the information about the incident, so I think it is better to ask a senior who is familiar with reporting the incident and other practical matters.

Depending on the type of incident, I think the required items will be determined to some extent.
In the case of injury, blackmail, murder, or accident, why don't you list the main items such as "the perpetrator", "the victim", "the damage/the perpetrator", "the number of deaths, injuries, and emergency transportation"?


2022-09-30 14:56

Just one example, separate the tables as follows:

Event (Event ID, Event Type Code, Time of Occurrence)
Case damage (Damage ID, Case ID, Damage Category Code, Damage Name)
Case Type (Code of Case Type, Name of Case Type)
Damage Type (Damage Type Code, Damage Type Name)

The contents are as follows:

Case Type: Snatching/Murder/Theft
The name of the damage...bag/ wallet/Mr. A
Type of damage: theft/damage/death/injury

Try using the keyword "normalization".

First of all, it is necessary to organize the information that Mr. Fumu says.


2022-09-30 14:56

If you have confirmed that you will not search (such as narrowing down by where) the detailed information data,

time of occurrence:datetime
More information: json

I think it's one option to make it with the data type of .

The disadvantage of this design is that the contents of json are often unindexed (depending on the database engine), so if you try to search for the contents, it will be very slow.


2022-09-30 14:56

There is a table like the one above, but every time the content of the incident increases, the details I want change, so the columns increase.

Rather than using RDBMS, document-oriented DBs such as MongoDB might be more appropriate.
Document-oriented DB manages data as a "document" rather than a matrix table.

The document is represented in JSON format, for example:

{
  Date and time of occurrence: March 3, 2019 10:00,
  "What Happens": "Snatch",
  "What's taken": "Bag"
}
{
  Date and time of occurrence: "March 3, 2019 11:11",
  "What Happened": "Murder",
  "Death": "Mr. A"
}
{
  Date and time of occurrence: "March 3, 2019 11:11",
  "What happened": "Theft",
  "What's taken": "Safe"
}
{
  Date and time of occurrence: "March 3, 2019 11:11",
  "What Happened": "Murder"
}

During registration, no prior schema definition is required, so you can register the required items for each document.

In this state, search for "Date and Time of Occurrence = March 3, 2019 11:11" or
You can also search for "What Happened = Murder"

However, there are advantages and disadvantages compared to RDBMS, so sometimes RDBMS is better.
Please review the requirements and select the one you want.


2022-09-30 14:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.