I have two erds show me best way to access data from tables i-e
The table one is Category and table second is Articles
TWO Tables ERD
Table Category
(CategoryId
CategoryName
CategoryDescription );
Table Articles
(ArticlesId
ArticlesTitle
ArticlesBody
ArticlesCreatedby
CategoryId (`forigen Key`FK));
i dont have that Reputation to Post Pics, but here is the link of the picture of diagramatic ERD.
http://i341.photobucket.com/albums/o377/pakistanihaider/relation1_zps06c6e6ec.png
OR
The table one is Category and table second is Articles and third one is Category & Articles
Three Tables ERD
Table Category
(CategoryId
CategoryName
CategoryDescription );
Table Articles
(ArticlesId
ArticlesTitle
ArticlesBody
ArticlesCreatedby
);
Table Category & Articles
(Category_id
Articles_id);
Also Diagramatic ERD of this Second Code:
http://i341.photobucket.com/albums/o377/pakistanihaider/relation_zpsea5d55a9.png
It depends on your data. If you only ever need one category per article, then option one will work. However if you might in the future require more than one category per article, your second option is better. The one thing you are missing is the second option, the Category & Articles table should have both fields as foreign keys.
The third table in the second option above is a joining table. It’s express purpose is to provide the links between the other two tables. This allows a many to many relationship (a category can have many articles, and an article can have many categories), whereas the first option only provides a one to many relationship (each article can only have one category).
The reason both fields in the articles table should be foreign keys is because they will always relate to records in other tables. By setting them as foreign keys, you are protecting your data input (it will error if you try and enter and ID that is incorrect), and you are helping the database to optimise any queries you do joining the data.