Difference between #7 and #8 of
Guidelines for good schema design

Revision #8 has been created by softark on Aug 14, 2018, 12:34:19 AM with the memo:

Fixed the link to the Chinese translation
« previous (#7) next (#9) »

Changes

Title unchanged

Guidelines for good schema design

Category unchanged

Tips

Yii version changed

1.1

Tags changed

database, schema design

Content changed

[...]
Yii supports the notion of table prefix, which is useful in shared hosting environments where _all_ your applications share a single database. By prefixing your blog table names with `blog_`, your timekeeping application table names with `time_`, etc. they can all live in the same database without conflicting with each other.

The prefix `tbl_` is commonly seen in many tutorials and samples.

But the **classes** should never contain these prefixes, because you don't have the same need to avoid conflicts: your blog application is different from your timekeeping application.

```php

class TblComment extends CActiveRecord { // NO
class Comment extends CActiveRecord { // YES
[...]
By calling the FK `userid`, the BELONGS_TO relation of `$model->user` forms naturally and easily:

```php

class Post extends CActiveRecord {
[...]
If you have to look it up, it makes the code much more difficult to read and maintain.

Translations
 
------------
 
 
- Chinese version: [Yii良好的架构(schema)设计指南](https://www.yiiwiki.com/6blog.csdn.net/cd_0227/article/details/50536390 "中文翻译") - Russian version: [Руководство для проектирования хорошей схемы базы данных](http://phptime.ru/blog/yii/28.html) - Japanese version: [DB スキーマ設計のガイドライン](https://qiita.com/items/63e68a0172a1d2f92b5c)
124 0
71 followers
Viewed: 121 785 times
Version: 1.1
Category: Tips
Written by: Steve Friedl
Last updated by: softark
Created on: Aug 27, 2011
Last updated: 5 years ago
Update Article

Revisions

View all history