Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i'm making a MySQL data base , my tables are: users, activitylog, activitytype.

to avoid repetitions i thought about including activitytype in each activity which is logged into activitylog table, for example:

1-Activity Types Table

2-Activity Log Table

enter image description here

Is it an interesting model if yes how could i do it ?

share|improve this question
How could i do it ? – Wozniak Mar 9 '14 at 20:22
Was my answer correct ? If so marked as ! – Up_One Mar 10 '14 at 2:25
up vote 3 down vote accepted

@Wozniak form what i can see you need the sql syntax t build this structure ! to do so use the syntax belew :

create table Activity_Types(
activity_type_id in,
activity_name varchar(20),
PRIMARY KEY (activity_type_id)

create table Activity_Log(
activity_id int,
user_id id,
activity_type_fk id,
activity_date date,
PRIMARY KEY (activity_id),
FOREIGN KEY (activity_type_fk) REFERENCES Activity_Types(activity_type_id)

Where foreign key that makes the relation is hold on the Activiy_log table under the activity_type_fk column.
to join this tables just use this columns !

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.