How to Map these Classes into a Relational data model?

41 Views Asked by At

I am doing a simple blog project for which I've come up with the following object class structure.

user class (email address, password)

blog_entry class ( title, body, dateposted, state[draft, published] )

comment class ( comment, date posted )

category class ( category name )

object relationships

  1. a user can post zero or more blog entries, a blog entry belong to one and only one user

  2. a user can publish one or more comments, a comment belong to one and only one user

  3. a comment belong to a one and only one blog entry, a blog entry can have zero or more comments

  4. a blog entry belong to one and only one category, category can exist without a blog entry

I need to know how to map these object structure(including relationships) into a relational data model for mysql. Since this is my first MVC project I don't have a clear understanding how to get this done properly.

Pl. advise.

PS: I've come up with following data model. Appreciate your ideas on this:

users
 - id
 - email_address
 - password

categories
 - id
 - category_name

blog_posts
 - id
 - post_title
 - post_contents
 - post_dateposted
 - post_state
 - users_id
 - categories_id

comments
 - id
 - comment
 - comment_dateposted
 - blog_posts_id
 - users_id

Thanks.

0

There are 0 best solutions below