0

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 ?

  • 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
3

@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 !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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