Question

I'm studying about 3-tier architectures and I have an issue to which I can not really seem to find a solution. Eventhough there are a lot of articles on the net about 3-tier architectures, none of them mention data models. Except in the context of MVC.

I have the following architecture: enter image description here

So what we see here is that each layer uses the data model. Suppose I have a new user that subscribes:

UI : * Get the data from the http request
     * Build a `UserModel()` with this data
     * Pass this `UserModel` to the application layer
APP: * Pass the `UserModel` to the DB layer
DB : * Format the `UserModel` to SQL and write to DB.

So effectively all layers have a notion of this data model. I'm wondering if this is in fact the whole point?

In contrast, suppose I wanted to resolve this I could make the UI pass the "raw" data (i.e., the values for a user in string format) to the application layer. The application layer would be the only layer that has a notion of the UserModel. It would thus create the UserModel with this data. How I would then proceed to pass it to the database layer without the DB layer having the notion of the model is tricky. So I have no clue on how to that.

In short, I'm pretty stuck. Any help is greatly appreciated.

Was it helpful?

Solution

It is indeed the whole point to use the data model objects in all layers. When creating new data in the GUI, Data Model objects are created in the presentation layer and passed to the data/persistence layer. When querying the data, the Data Model objects are instantiated in the persistence layer and passed to the presentation layer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top