1

Does the data tier verify any of the user's input? or does it just store data?

Example - User adds email to his profile.

Is this right?

Presentation Tier - Verify Email format is valid (client side)

Logic tier

  • Verify Email format is valid (again?)
  • Set Email type (ie is Primary email?)
  • Check record limit allowed to store email

Data:

  • Store the email record

Logic:

  • Send Notification to presentation tier
  • Send Notification via Email
001
  • 62,807
  • 94
  • 230
  • 350

2 Answers2

2

Note :

Data layer task is to connect with the database and to perform CRUD operation if you want to apply extra validation logic than you must do it in the logical layer

You architecture changes

Presentation Tier -

  • Verify Email format is valid (client side)

Logic tier

  • Verify Email format is valid (again?) - No need to do it again
  • Set Email type (ie is Primary email?)
  • Check record limit allowed to store email

Data Layer:

  • allow to connect with the database
  • perform CRUD operation

Data Store i.e DataBase

  • Store the email record

Return

DataLyer

  • Informs logic layer data inserted propertly

Logic Layer:

  • Send Notification to presentation tier either data inserted/updated properly
  • Send Notification via Email if Data Inserted/Updated properly else log error
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263
  • He should validate the password again. Client side validation can be bypassed (note the ASP.NET tag) – jgauffin Sep 29 '11 at 07:04
  • @jgauffin - i think beofre passing data to business layer he can make use of serverside validation and do validate the thing rather than more reply on client side – Pranay Rana Sep 29 '11 at 07:06
  • What about set "Created_DateTime" should that be in the Data Layer? – 001 Sep 29 '11 at 07:14
  • Make sure Email is stored in "lower" case where does this go? – 001 Sep 29 '11 at 07:14
  • Should the Data layer make sure that valid data is being stored or it doesn't care? it just stores anything. – 001 Sep 29 '11 at 07:16
  • @001 - data layer task is to connect with the database and to perform CRUD operation if you want to apply extra validation logic than you must do it in the logical layer – Pranay Rana Sep 29 '11 at 07:35
2

Every layer has its own set of contracts with outside world.

You shouldn't do or not do something based on assumption that it may have been done on earlier layer (like validation)

However DataLayer doesn't verify email address formats. Its not part of its responsibilities. It shouldn't even understand what an email looks like except for a fact that it is string of some specific length.

Muhammad Hasan Khan
  • 34,648
  • 16
  • 88
  • 131
  • What about Created_DateTime, should this be created in the data layer? what about the logic layer messed up and the email is not in the correct format, does the data layer store invalid data? – 001 Sep 29 '11 at 07:37
  • 1
    Data layer responsibility is to store and retrieve the data. Verifying the formats is job of business layer. – Muhammad Hasan Khan Sep 29 '11 at 08:02