Mysql
從舊表創建部落格新表
我正在從舊表重新創建數據庫結構。新表應該優化並且易於理解。
在舊數據庫中,開發人員使用
video
表名來儲存影片部落格。但是我不認為它是儲存影片部落格的正確名稱。下面是舊表video: _attributes: { phpName: Video } ID: { type: INTEGER, size: '11', primaryKey: true, autoIncrement: true, required: true } coupon_banner_id: { type: INTEGER, size: '10', foreignTable: coupon_banner, foreignReference: id, onUpdate: CASCADE, onDelete: CASCADE } blog: { type: TINYINT, size: '1', required: true, defaultValue: '0' } catid: { type: INTEGER, size: '11', required: true, defaultValue: '0' } title: { type: VARCHAR, size: '100', required: true, defaultValue: '' } description: { type: LONGVARCHAR, required: true } blogtopid: { type: INTEGER, size: '11', required: true, defaultValue: '1' } video: { type: VARCHAR, size: '50', required: true, defaultValue: '' } vlink: { type: LONGVARCHAR, required: true } picture: { type: VARCHAR, size: '255', required: true, defaultValue: '' } video_picture_alt: { type: VARCHAR, size: '255', required: false, defaultValue: '' } apicture: { type: VARCHAR, size: '150', required: true, defaultValue: '' } usid: { type: INTEGER, size: '11', required: true, defaultValue: '0' } datein: { type: TIMESTAMP, required: true, defaultValue: '0000-00-00 00:00:00' } koview: { type: INTEGER, size: '11', required: true, defaultValue: '0' } korating: { type: INTEGER, size: '11', required: true, defaultValue: '0' } kototrat: { type: INTEGER, size: '11', required: true, defaultValue: '0' } konota: { type: INTEGER, size: '11', required: true, defaultValue: '0' } kocomm: { type: INTEGER, size: '11', required: true, defaultValue: '0' } kofavorite: { type: INTEGER, size: '11', required: true, defaultValue: '0' } kofeatured: { type: INTEGER, size: '11', required: true, defaultValue: '0' } koorder: { type: INTEGER, size: '11', required: true, defaultValue: '999' } commtime: { type: TIMESTAMP, required: true, defaultValue: '0000-00-00 00:00:00' } is_active: { type: BOOLEAN, required: true, defaultValue: '0'} slug: { type: VARCHAR, size: '100', required: true, defaultValue: '' } video_cat: _attributes: { phpName: VideoCat } ID: { type: INTEGER, size: '11', primaryKey: true, autoIncrement: true, required: true } category: { type: VARCHAR, size: '50', required: true, defaultValue: '' } meta_title: { type: VARCHAR, size: '255', required: true, defaultValue: '' } category_desc: { type: LONGVARCHAR, required: false, defaultValue: '' } meta_desc: { type: LONGVARCHAR, required: false, defaultValue: '' } position: { type: INTEGER, size: '3', required: true, defaultValue: '999' }
我將其重命名並優化如下:
article: id, category_id, user_id, title, slug, description, video_link, video_description, video_thumbnail, Video_thumbnail_alt, article_description ( I will be using CKEditor here so styles, which data type is better text or longvarchar? ), is_active (int or boolean which one is better), is_featured (int or boolean which one is better), is_favorite (int or boolean which one is better), created_at DATETIME, updated_at DATETIME
您認為我的新優化表還有哪些需要改進的地方?我還想知道將影片和文章儲存在單獨的表中是否更好,或者可以像我一樣儲存在同一個表中?
是否單獨的表 - 這取決於
- 大多數列是否相同?
- 表上的大多數操作是否相同?
如果一個影片可以屬於多個類別,您將需要一個多對多映射表。
什麼是
position
,如何維護?