Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8524447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:41:20+00:00 2026-06-11T07:41:20+00:00

i would like to learn from you on designing the database schema: ie. my

  • 0

i would like to learn from you on designing the database schema:

ie. my problem is 1 activity has 1..* date_held

eg. activity name is

"see movie" has date_held on 1 Sep

"shopping" has date_held on 2 Sep , 5 Sep, 6 Sep

Method1

so my current database design is

---------------------------
Activity Table
---------------------------
id|name|date_held

1|see moive|20120901

2|shopping|20120902

3|shopping|20120905

4|shopping|20120906

You can see that shopping record is duplicated 3 time. I think it seem not good.

Method2

So I divide into 3 table

---------------------------
Activity Table
---------------------------



id|name

1|see moive

2|shopping


---------------------------
Date Table
---------------------------
id|date

1|Sep 1

2|Sep 2

3|Sep 5

4|Sep 6



---------------------------
Activity_Date Table
---------------------------
activity_id|date_id

1|1

2|2

2|3

2|4

But I think method 2 is very confused. Any one can give me a suggestion how to do table design on 1 activity match 1..* date_held?

Thanks!!

Hi Branko Dimitrijevic

after I think a few hour , i discover another method, i.e. use redis json format

{

"name":"shopping",

"date":[

"Sep1"

]

},

{

"name": "see movie",

"date":[

"Sep2","Sep5","Sep6"

]

}

It seem very easier~ 😀

But let me think your suggestion..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:41:22+00:00Added an answer on June 11, 2026 at 7:41 am

    You can see that shopping record is duplicated 3 time.

    The value of the name field, taken alone, does repeat in different rows. The whole records (i.e. rows) are not repeated.

    Logically, if the same activity is repeated on multiple dates, the same piece of data identifying that activity1 must be repeated for each of these dates. There is no magic and all the relevant combinations must be listed in the database. Fortunately, databases are good at handling huge amounts of data.

    I think there are two issues here:

    1. Do you need a surrogate key id? If there can never be the same activity on the same date, then the {name, date_held} is a “natural” key, no matter whether you’ll add another “surrogate” key such as id. So unless you actually need the the surrogate PK, you can just leave the natural key as primary. If there can be multiple activities per day, consider replacing date_held with datetime_held.

    2. Do you need a third table? If you want to associate more information than just name with each activity, or you want an activity to be able to exist even without ever being held, then you need it at the logical level anyway. But even if you don’t, at the purely physical level, using a surrogate PK in a third table would save you from repeating a string, and instead allow you to repeat the (slimmer) integer. You could potentially save space (and cache performance) with that, but could also require more JOINing. As you see, it’s a matter of balance and measurements can be an invaluable tool for picking the right one.


    1 Be it activity name or ID.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It is always better to learn from other developers experiences. I would like to
I would like to learn from and possibly use the section serializer that Jeff
I would like to learn the best practices to employ when creating a database
I would like learn about .htaccess file, from the very basic to the complex
I would like to learn more about osdev. So I thought about learning from
I would like to learn about HTML forms. For example, I have 2 input
I would like to learn how to use NUnit. I learn best by reading
I would like to learn how setup prefix routing like there is in cakephp
I would like to learn how to select weighted items. For example : I
I would like to learn how to use binding functions. Here is the idea:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.