As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have many important question about E-Commerce solution database :
For validation your form fields, for example (Null Value can not be inserted , Unique value , just number input, Date validation and etc.)
what's the best way :
a) Use function with T-SQL in my database on the table fields and handle with Try-Catch
b) Use .NET validation component
c) Use Ajax component
d) Use businesses method
If I use Entity Framework, should I use stored procedures or I can use insert, update and delete method from Entity Framework?
Which one is the best way for E-Commerce solution ?
For E-Commerce solution we should 3 or 5 step normalization or create Flat table ?
For E-Commerce solution Linq To Sql or Entity Framework ? which one and why ?
These are very important questions for me
Thanks
I think the right answer is more nuanced. The 'best' way means validating at many places along the way.
You should validate in the form using JavaScript/jQuery. Tell users about required values, improper formats, etc.
Controllers should bind and validate values they receive.
Services should never trust a UI. They also have additional information that a UI can never have: business rules for validity. Those are context-dependent and may change. Let the execution of business rules be done by the middle tier services.
Validating in the database, using constraints like UNIQUE, triggers or stored procedures, should be the last resort and only used if the database is shared by several applications. I wouldn't want to wait until I was persisting data to find out that it was invalid. The earlier you can inform a user, the better.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Why is a data layer used while we can write most of the code in stored procedures itself? What are the advantages and disadvantages in it?
Data layer is an important layer in 3 tier architecture, which handles all the database related tasks. My question is that, whether we can achieve this using a stored procedure itself in most of the cases? In that case, what is the major advantage in using that layer?
EDIT:
The question was just to get clear idea about the usage of data layer and database stored procedures. I have got an answer below which helped me in that.
The 3-tier approach is for when you wish to maybe use different Database Engine types.
From Multitier architecture
Data tier
This tier consists of database servers. Here information is stored and
retrieved. This tier keeps data neutral and independent from
application servers or business logic. Giving data on its own tier
also improves scalability and performance.
In stored procedure goes your query logic, in data access layer you connect with database engine
MSDN,
N-Tier-Architecture-and-Tips have good insight on n-tier architecture
You can't unit test stored procs very easily because you can't easily mock the data in the database
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm developing an MVC 3 application, and thought about using ASP.NET's default users, roles and profiles implementation. I created the aspnetdb database and can authenticate users very quickly - no problem.
The problem begins when I want to associate things with users. For instance, I want users to upload images - each image should be associated to the user who uploaded it.
If the aspnet_Users table wasn't in a different database, I would have just added a UserId column to the Images table, set the appropriate foreign key and not worry about it anymore. That's the straightforward way used in Django as well. Unfortunately, SQL Server 2008 doesn't support foreign key constraints between databases.
I can create all the ASP.NET tables in my main database, but I'm not sure of the downside.
This issue is probably encountered by anybody creating an ASP.NET application. What's the best practice?
You should be adding the asp.net membership provider tables to your main database. The only reason I can think that you wouldn't do this is if they are self contained (e.g. you're creating an access control project).
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am trying to get some ideas for storing text in a database. This data will be used on a web page but also will be used to share with other users outside of the web page. There are instances that I would like to use italicization or bold text, break into paragraphs, etc for the web page. I am also going to be allowing others to access the db to pull this information into their own application may be a web page, another database, vb application, etc. What would be the best way to do this and not have a format that may not be supported by the clients program? I read some post where they suggested to store the data as XML and then I could strip it out if I didn't need it. I am not that advanced so seems it may be difficult. I welcome all suggestions....
Avoid storing rendering data in your database - store just the data in its rawest form. Let the user of the data decide how to format it. Perhaps, if formatting is part of the data (ie you're storing "documents") you could store as markup/markdown (good point from #pst).
Another way of looking at it is to store the data without assuming what it's used for. That way, it's easiest to maintain and use for your initial uses, and more in the future.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Are there cases where database designers are not allowed to know the details of the data? I am looking for real-world examples to learn from — please.
I can't help but tell a story about database nightmares. One of the worst was when Amazon was first growing. Initially they only sold books, then expanded to music, and then to many other things.
For a period of about two years, Amazon would announce a new market every two or three months -- children's clothing, housewares, garden supplies, food, and so on. The database folks were tasked with developing and supporting the systems for the product lines. However, Amazon considered the new product announcements to be highly, highly secret.
In particular, the data warehouse people would be kept further from the loop. Sometimes, they would find out about a new line of business by reading news -- and then have to support it in the data warehouse.
So, they had to develop a flexible database to meet unannounced business needs.
In any business environment, there are new needs that arise. I would suggest a book such as Ralph Kimball's "Data Warehouse Toolkit" for more background on how to develop a fairly robust system.
I am currently working at a company that stores very private personal information. I am not allowed access to the production database. For our development and test environments, we replace all names, addresses, and other personal information with randomly generated information.
Yes, I've often seen databases allow for custom data to be defined by the user. The basic approach is to design a meta data system for your database. Then allow entities associations with custom fields. You wouldn't want to do this for all your data, otherwise you'll just end up with a database in a database, but for dynamically adding a number of custom fields this approach works well.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I'm looking for a document oriented database to store over millions of invoices with fast reporting speed.
I find some options such as MongoDB, Ravendb, Couchdb but I don't know the risk of performance failure vs. Sql Server Xml type column.
The source of this question is here.
Fast reporting is something that you want to do in sql server. I'm not aware of a good NoSQL solution for this scenario.
RavenDB has the index replication bundle that enables you to replicate an index to a sql table, so that you can do some advanced reports on them.
Reza,
RavenDB seems like a good match here. It all depends on what you are actually calling "reporting".
Doing things like "how many invoices are there for last month" is easy in RavenDB.
As is doing things like "how much money does Northwind owe us?"
We don't recommend RavenDB for reporting for the specific case where you have dynamic reporting needs such as the need to do on the fly aggregation.
What is it that you are actually trying to do with regards to reporting?
That aside, invoices is a nice place where RavenDB truly shines, especially given the other parameters of this question with the dynamic nature of the invoices.
but I don't know the risk of performance failure vs. Sql Server Xml type column.
Epic fail already here. Invoices are relational data in most cases (in all you need) so address links, line items, numbers and prices are in tables, not XML data type. This is the "ok, so - you planned to wkr at McDonalds, not in our team?" level design decision.
What line items and invoices may have is additional data in XML (like timesheets etc.) but if you run accounting, you dont run it as documents.