`
jiajie0531
  • 浏览: 29403 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Active Record Basics 1 What is Active Record?

阅读更多

version: rails 4

 

概要

 

  • ORM和Active Record是什么?以及他们在Rails中是怎样使用的?
  • Active Record如何融入到MVC框架中?
  • 如何使用Active Record模型在关系型数据库中来操作数据的存储?
  • Active Record模式命名的规则。
  • 数据库迁移,验证和回滚的概念。

 

1 What is Active Record?

什么是Active Record?

 

Active Record 是MVC中的M—模型,它是系统的一个层,主要职责是实现业务数据和逻辑。Active Record用来对业务对象的创建和使用,它的数据需要持久性地存储至数据库中。Active Record模式的一种实现方式可以这样来描述,它是一个ORM对象关系映射系统。

 

1.1 The Active Record Pattern

Active Record模式

 

Active Record was described by Martin Fowler 在他的书《企业应用架构模式》中。在Active Record中,对象拥有持久性数据和行为,其行为就是操作数据。 Active Record觉得受保护的数据存储逻辑是对象的一部分,将会让用户学习到对于那个对象如何从数据库中去写入和读取。

 

1.2 Object Relational Mapping

对象关系映射

 

通常简写为ORM,对象关系映射,ORM是一个技术,它联系应用程序的富对象与关系数据库系统中的数据表。使用ORM,在一个应用程序中对象的属性和关联性能够被简单地从数据库中保存和获取,而不需要直接写SQL语句,以及较少的数据库存取代码。

 

1.3 Active Record as an ORM Framework

Active Record 是作为一个ORM的框架

 

Active Record给我们提供了一些机制,下面是最重要的特征:

  • 描述models和他们的数据。
  • 描述这些models之间的关联性。
  • 描述这些相关联的models之间的继承关系。
  • 在models被持久性地保存到数据库之前,验证models。
  • 以面向对象的方式执行数据库操作。

 

 

 

original text: http://guides.rubyonrails.org/active_record_basics.html

0
0
分享到:
评论

相关推荐

    Deep Learning, Vol. 1: From Basics to Practice

    1: From Basics to Practice By 作者: Andrew Glassner Pub Date: 2018 ISBN: n/a Pages: (909 of 1750) Language: English Format: PDF People are using the tools of deep learning to change how we think ...

    Active Directory Cookbook, 3rd Edition.pdf

    Covers the basics of searching Active Directory: creating, modifying, and deleting objects, using LDAP controls, and importing and exporting data using LDAP Data Interchange Format (LDIF) and comma-...

    Pro ActiveRecord Databases

    And almost all of those books actually do a great job of introducing you to the basics of Active Record; they go a long way toward getting you started with the library. However, because they ...

    MongoDB Basics

    Developers and relational database admins who need to get up to speed quickly on what MongoDB is, how it works, and how to use it. Table of Contents Ch. 1: Introduction to MongoDB Ch. 2: Installing ...

    HTML Basics

    Welcome to HTML Basics. This workshop leads you through the basics of Hyper Text Markup Language (HTML). HTML is the building block for web pages. You will learn to use HTML to author an HTML page to ...

    Rails Crash Course(No Starch, 2014)

    In Part II, you'll take your skills to the next level as you build a social networking app with more advanced Ruby tools, such as modules ...advanced data modeling techniques within Rails's Active Record....

    MPLS Basics MPLS Basics

    MPLS BasicsMPLS Basics

    Android.Programming.The.Easy.Way

    What is Android Development? Basics of Development What is XML What is Java What is the Development Environment Eclipse Android Studio Setting up PATH for Windows and Mac OSX Creating a Project Coding...

    Basics for EDI

    This is the Basics for EDI. EDI is hot in nowadays.

    Blockchain Basics: A Non-Technical Introduction in 25 Steps

    Why it is needed and what problem it solves Why there is so much excitement about the blockchain and its potential Major components and their purpose How various components of the blockchain work and ...

    FFmpeg Basics.zip

    1. **FFmpeg 基本概念** FFmpeg 是一套跨平台的命令行工具,主要用于处理音频和视频文件。它包括 ffmpeg、ffplay、ffprobe 和 ffserver 四个主要组件。ffmpeg 用于转换和处理多媒体文件,ffplay 是一个简单的播放器...

    英文原版-The Basics of Process Improvement 1st Edition

    Unlikeother books that promote a specific process and performance improvement discipline, this book shows organizations how to achieve success by fixing basic operational issues and problems using a ...

    WTL Makes UI Programming a Joy, Part 1: The Basics - Samples

    It is an SDK sample produced by members of the ATL (Active Template Library) team chartered with building an ATL-based wrapper around the windowing portions of the Win32 API. Since version 2.0, ATL ...

    LabWindows CVI BASICS I & II

    本系列教程“LabWindows CVI BASICS I & II”旨在帮助初学者和有一定经验的工程师掌握这款强大的工具的基础知识。 在“CVI BASICS I Course”中,学习者将深入理解LabWindows CVI的基础概念和核心功能。这部分教程...

    Deep Learning, Vol. 2: From Basics to Practice

    Our goal is to give you all the basics you need to understand deep learning, and then show how to use those ideas to construct your own systems. Everything is covered from the ground up, culminating ...

    英文原版-Learning Radiology Recognizing the Basics 3rd Edition

    A must-have for anyone who will be required to read and interpret common radiologic images, Learning Radiology: Recognizing the Basics is an image-filled, practical, and easy-to-read introduction to ...

    The Basics of Cloud Computing

    The Basics of Cloud Computing

    SAP CRM 100 Basics

    1. **销售自动化**:通过提高销售团队的工作效率和效果来增加收入。 2. **市场营销管理**:帮助规划、执行和分析营销活动,提高ROI(投资回报率)。 3. **客户服务和支持**:提供工具和技术来改善客户体验,增强客户...

    Cloud Computing Basics

    Cloud Computing Basics springer 2014

Global site tag (gtag.js) - Google Analytics