3

When we detect these items for visitors:

  • Browser name
  • Browser version
  • OS name
  • OS version
  • Screen resolution
  • Screen depth
  • Flash enabled
  • ...

Should these all be stored in the database in separate columns or should I be storing it all as a user agent string and then breaking it down in the application?

And should I use varchar(255) for this just to be safe or are there well-defined datatypes for these items? I use MySQL and PHP

4

3 に答える 3

3

It really depends on what you want to do with the information. If you plan to use the data for very detailed statistics, use separate columns so you can run detailed queries like "show all screen resolutions for users with Internet Explorer 6" and such.

If you don't expect to need such detailed statistics, storing the user agent string in one field will usually work fine.

于 2010-12-20T00:20:54.257 に答える
2

各項目を独自の列に格納する必要があります。これにより、データのクエリと要約を簡単に行うことができます。

挿入時に一度解析するのは安価です。すべてのクエリの解析は非常にコストがかかります。

于 2010-12-20T00:30:49.340 に答える
1

これらのアイテムにはデータ型が定義されていないため、varchar(255)またはそれ以下を使用できます。この値を別々のフィールドでデータベースに追加することをお勧めします。これは、パフォーマンスに顕著な影響を与えないためです + 挿入は 1 回実行され、読み取りは複数回行われるため、読み取りごとではなく、書き込み時に 1 回分割しないのはなぜですか? :)

于 2010-12-20T00:25:08.170 に答える