How do I create a MYSQL table?

I built a really basic php / mysql site for an architect that uses a single "projects" table. The website presents various projects that he has worked on.

Each project contained one piece of text and one series of images.

Source project table (create syntax):

CREATE TABLE `projects` (
  `project_id` int(11) NOT NULL auto_increment,
  `project_name` text,
  `project_text` text,
  `image_filenames` text,
  `image_folder` text,
  `project_pdf` text,
  PRIMARY KEY  (`project_id`)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;

The client now requires the following, and I'm not sure how to handle the extensions in my database. My suspicion is that I will need an extra table.

Each project now has "pages".

Pages

contain either ...

  • Single image
  • One piece of text
  • One image and one piece of text.

Each page can use one of three layouts.

4 ( ), , .

( ):

CREATE TABLE `projects` (
  `project_id` int(11) NOT NULL AUTO_INCREMENT,
  `project_name` text,
  `project_pdf` text,
  `project_image_folder` text,
  `project_img_filenames` text,
  `pages_with_text` text,
  `pages_without_img` text,
  `pages_layout_type` text,
  `pages_title` text,
  `page_text_a` text,
  `page_text_b` text,
  `page_text_c` text,
  `page_text_d` text,
  PRIMARY KEY (`project_id`)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;

MYSQL . !

+1
1

- .

.

CREATE TABLE projects (
   project_id int not null primary key auto_increment,
   project_name varchar(128),
   -- ...
);

CREATE TABLE pages (
   page_id int not null primary key auto_increment,
   project_id int not null, 
   pagetext text,
   image varchar(128), 
   -- ...
);

.

: " 0-N ", , page_id ( , project_id foreign )

+3

All Articles