Is there any difference between Actice Record and ORM? some of the documentations says both are same. is that true?
Actice记录和ORM有什么区别吗?有些文件说两者都是一样的。这是真的吗?
3 个解决方案
#1
3
Object Relational Mapping (ORM) is the technique of accessing a relational database using an object-oriented programming language. Object Relational Mapping is a way to manage database data by "mapping" database tables to classes and instances of classes to rows in those tables.
对象关系映射(Object Relational Mapping, ORM)是一种使用面向对象编程语言访问关系数据库的技术。对象关系映射是一种通过将数据库表“映射”到类并将类实例映射到这些表中的行来管理数据库数据的方法。
Active Record is just one of such ORMs, others include:
活动记录只是这样的ORMs之一,其他包括:
- Sequel
- 续集
- DataMapper
- DataMapper
- Squeel
- Squeel
- Ruby Object Mapper etc.
- Ruby对象映射器等。
Read more here https://github.com/learn-co-students/active-record-mechanics-crud-v-000#orm-vs-active-record
阅读更多这里https://github.com/learn - co - students/active -记录-力学- crud v - 000 # orm-vs-active-record
#2
0
Object Relational Mapping (ORM):
对象关系映射(ORM):
simplify the use of databases in applications.
简化应用程序中数据库的使用。
Use objects to hold database records
使用对象保存数据库记录
- One class for each table in the database
- 数据库中的每个表都有一个类
- Objects of the class correspond to rows in the table
- 类的对象对应于表中的行
-
Attributes of an object correspond to columns from the row
对象的属性对应于行中的列
- Manage the movement of information between objects and the back-end database.
- 管理对象和后端数据库之间的信息移动。
- Manage relationships between tables (joins), turn into linked data structures.
- 管理表(连接)之间的关系,将其转换为链接数据结构。
ActiveRecord Basics
ActiveRecord基础知识
Model: A Rails class corresponding to a database table ActiveRecord:
模型:与数据库表ActiveRecord对应的Rails类:
- Base class for models in Rails
- Rails中的模型的基类。
- Implements Object Relational Mapping
- 实现了对象关系映射
Example Table
例表
<table>
<tbody>
<tr>
<th> id </th>
<th>name</th>
<th>birth</th>
<th>gpa</th>
<th>grade</th>
</tr>
</tbody>
<tbody>
<tr>
<td> 1 </td>
<td> Anderson </td>
<td> 1987-10-22 </td>
<td> 3.9 </td>
<td> 2009 </td>
</tr>
<tr>
<td> 2 </td>
<td> Jones </td>
<td> 1990-04-16</td>
<td> 2.4 </td>
<td> 2012 </td>
</tr>
</tbody>
</table>
Create a class for this table (app/models/student.rb):
为该表创建一个类(app/models/student.rb):
class Student < ActiveRecord::Base
end
Or, just use the script/generate program:
或者,使用脚本/生成程序:
ruby script/generate model student
- ActiveRecord examines the database schema for this table and makes appropriate attributes and methods available in the class automatically
- ActiveRecord检查此表的数据库模式,并自动在类中提供适当的属性和方法
For more information Click Here.
更多信息请点击这里。
#3
0
I figured it was a pretty simple question, so I' gonna stick to a simple response :
我觉得这是一个非常简单的问题,所以我将坚持一个简单的回答:
- ActiveRecord is an ORM for the ruby language.
- ActiveRecord是ruby语言的ORM。
- Not all ORMs are in ruby, for example Django ORM is in python
- 并非所有ORM都在ruby中,例如Django ORM在python中
- There is other ruby ORMs than ActiveRecord : https://www.ruby-toolbox.com/categories/orm
- 除了ActiveRecord还有其他ruby orm: https://www.ruby-toolbox.com/classies/orm
=> ActiveRecord ⊂ ruby ORMs ⊂ ORMs
= > ActiveRecord⊂ruby orm⊂orm
#1
3
Object Relational Mapping (ORM) is the technique of accessing a relational database using an object-oriented programming language. Object Relational Mapping is a way to manage database data by "mapping" database tables to classes and instances of classes to rows in those tables.
对象关系映射(Object Relational Mapping, ORM)是一种使用面向对象编程语言访问关系数据库的技术。对象关系映射是一种通过将数据库表“映射”到类并将类实例映射到这些表中的行来管理数据库数据的方法。
Active Record is just one of such ORMs, others include:
活动记录只是这样的ORMs之一,其他包括:
- Sequel
- 续集
- DataMapper
- DataMapper
- Squeel
- Squeel
- Ruby Object Mapper etc.
- Ruby对象映射器等。
Read more here https://github.com/learn-co-students/active-record-mechanics-crud-v-000#orm-vs-active-record
阅读更多这里https://github.com/learn - co - students/active -记录-力学- crud v - 000 # orm-vs-active-record
#2
0
Object Relational Mapping (ORM):
对象关系映射(ORM):
simplify the use of databases in applications.
简化应用程序中数据库的使用。
Use objects to hold database records
使用对象保存数据库记录
- One class for each table in the database
- 数据库中的每个表都有一个类
- Objects of the class correspond to rows in the table
- 类的对象对应于表中的行
-
Attributes of an object correspond to columns from the row
对象的属性对应于行中的列
- Manage the movement of information between objects and the back-end database.
- 管理对象和后端数据库之间的信息移动。
- Manage relationships between tables (joins), turn into linked data structures.
- 管理表(连接)之间的关系,将其转换为链接数据结构。
ActiveRecord Basics
ActiveRecord基础知识
Model: A Rails class corresponding to a database table ActiveRecord:
模型:与数据库表ActiveRecord对应的Rails类:
- Base class for models in Rails
- Rails中的模型的基类。
- Implements Object Relational Mapping
- 实现了对象关系映射
Example Table
例表
<table>
<tbody>
<tr>
<th> id </th>
<th>name</th>
<th>birth</th>
<th>gpa</th>
<th>grade</th>
</tr>
</tbody>
<tbody>
<tr>
<td> 1 </td>
<td> Anderson </td>
<td> 1987-10-22 </td>
<td> 3.9 </td>
<td> 2009 </td>
</tr>
<tr>
<td> 2 </td>
<td> Jones </td>
<td> 1990-04-16</td>
<td> 2.4 </td>
<td> 2012 </td>
</tr>
</tbody>
</table>
Create a class for this table (app/models/student.rb):
为该表创建一个类(app/models/student.rb):
class Student < ActiveRecord::Base
end
Or, just use the script/generate program:
或者,使用脚本/生成程序:
ruby script/generate model student
- ActiveRecord examines the database schema for this table and makes appropriate attributes and methods available in the class automatically
- ActiveRecord检查此表的数据库模式,并自动在类中提供适当的属性和方法
For more information Click Here.
更多信息请点击这里。
#3
0
I figured it was a pretty simple question, so I' gonna stick to a simple response :
我觉得这是一个非常简单的问题,所以我将坚持一个简单的回答:
- ActiveRecord is an ORM for the ruby language.
- ActiveRecord是ruby语言的ORM。
- Not all ORMs are in ruby, for example Django ORM is in python
- 并非所有ORM都在ruby中,例如Django ORM在python中
- There is other ruby ORMs than ActiveRecord : https://www.ruby-toolbox.com/categories/orm
- 除了ActiveRecord还有其他ruby orm: https://www.ruby-toolbox.com/classies/orm
=> ActiveRecord ⊂ ruby ORMs ⊂ ORMs
= > ActiveRecord⊂ruby orm⊂orm