Wiki source code of Your First Rest Project
Version 28.1 by Pascal Robert on 2011/12/27 11:18
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
28.1 | 1 | {{toc}}{{/toc}} |
| |
21.1 | 2 | |
| |
5.1 | 3 | = Introduction = |
| 4 | |||
| 5 | In the first part of the Blog tutorial, you will learn: | ||
| 6 | |||
| 7 | * How to create a EOModel for the database (we will use H2) | ||
| 8 | * How to use migrations to create the database tables | ||
| 9 | * How to use ERRest to create blog posts with JSON format and how to display the blog posts in HTML for readers | ||
| 10 | |||
| 11 | = Create the database model = | ||
| 12 | |||
| 13 | We will build a small database model for the blog. The database will have two tables: BlogEntry and Author. | ||
| 14 | |||
| 15 | BlogEntry will have the following columns: | ||
| 16 | |||
| |
28.1 | 17 | |= Column name |= Type |= Constraints |
| 18 | | id | integer | primary key | ||
| 19 | | title | string(255) | | ||
| 20 | | content | string(4000) | | ||
| 21 | | lastModified | timestamp | | ||
| 22 | | creationDate | timestamp | | ||
| 23 | | author | integer | relation with Author | ||
| |
5.1 | 24 | |
| 25 | Author will have the following columns: | ||
| 26 | |||
| |
28.1 | 27 | |= Column name |= Type |= Constraints |
| 28 | | id | integer | primary key | ||
| 29 | | firstName | string(100) | | ||
| 30 | | lastName | string(100) | | ||
| 31 | | email | string(150) | unique | ||
| 32 | | passwd | string(16) | | ||
| |
5.1 | 33 | |
| 34 | To create the database, we will first create a EOModel and use migrations to build the database on the file system (H2 will take care of creating the database file). |