IAC 2024 - IA Fast Track to Search Focused AI Solutions
Active Records Barcamp Cameroon 2009
1. Active Record Presentation by Mambe Churchill Nanje CEO, www.afrovisiongroup.com At Barcamp Cameroon 2009
2. What is Active Record? Active Record is an implementation of Object Relational Mapping where in a database is manipulated by highly linked objects(MODELS) interfacing the database tables and their content e.g instead of SELECT * FROM accounts WHERE user=1 with Active records we do user=new User(1); //sql gets generated for you
3.
4. HOW IT WORKS Example: car park management system Database of Cars Code without Active Record: connection=new Connection(h,u,p); query='select * from cars where id=1'; rs=connection.statement.execute(query); car=rs.get(0); print(car.brand); //mercedes print(car.owner); //francis Code With Active Record: database=new Database(h,u,p); car=database.get('cars',1); print(car.brand); //mercedes print(car.owner); //francis
5.
6.
7.
8.
9. Advantages of Active Record • Productivity – Eliminates lots of repetitive code – focus on business logic – Database code is generated automatically • Maintainability – Fewer lines of code – easier to understand – Easier to manage change in the object model • Performance – Lazy loading – associations are fetched when needed – Caching • Database vendor independence – The underlying database is abstracted away – Can be configured outside the application
10.
11. Thank you For more informationa about me www.afrovisiongroup.com http://mambenanje.blogspot.com www.twitter.com/mambenanje www.facebook.com/mambenanje other links www.blackamphi.com www.nexdimempire.com