Home » Fóruns » Database Administration and SQL Programming
 
Designing the Database Tables (521 visualizações)
Designing the Database Tables Postado em 26/06/2018 02:38 por hpsolcenter
Think of the basic components of a forum: topics and posts. A forum?if properly used by its patrons?should have several topics, and each of those topics will have one or more posts by users. Knowing that, you should realize that the posts are tied to the topics through a key field. This key forms the relationship between the two tables.

Think about the requirements for the topics themselves. You definitely need a field for the title, and subsequently you may want fields to hold the creation time and the identification of the user who created the topic. Similarly, think of the requirements for the posts: You want the text of the post, the time it was created, and the person creating it. Most importantly, you need that key to tie the post to the topic.

The following two table creation statements create these tables, called forum_topics and forum_posts:

mysql> create table forum_topics (
-> topic_id int not null primary key auto_increment,
-> topic_title varchar (150),
-> topic_create_time datetime,
-> topic_owner varchar (150)
-> );
Query OK, 0 rows affected (0.03 sec)

mysql> create table forum_posts (
-> post_id int not null primary key auto_increment,
-> topic_id int not null,
-> post_text text,
-> post_create_time datetime,
-> post_owner varchar (150)
-> );
Query OK, 0 rows affected (0.00 sec)


https://hpsolcenter.com/hp-printer-support/

hpsolcenter / HP SOL CENTER

Designing the Database Tables (521 previews)
 
Home » Fóruns » Database Administration and SQL Programming