I am developing an asp.net application ,, currently i'm using Sql Server 2008 as backend.
However i have been asked to develop one application with multiple databases (oracle,sql server,mysql etc). Is it possible to achieve this.Is it a feasible solution.What may be the possible disadvantages associated with it.
Thanks
This should be feasible, but it might not be easy.
You'll need a Data Access Layer that insulates you from the details of each database, as each database will have slightly different syntax in it's language, meaning you (probably) won't be able to write one query that'll work across them all. You haven't said what the domain of your system is, but in, let's say, a bookshop your DAL would have methods like GetBooks, GetBook, GetCustomer etc.
Underneath your DAL you'll probably then have a set of different .NET assemblies, each of which knows how to run your queries against one database (SQL Server, Oracle etc). When one of the methods in your DAL is called, your DAL passes that onto the appropriate assembly to actually make the call and return the results to your application back through the DAL. Your DAL will need to be able to create instances of the classes in the assemblies, there's a few different ways to do this but I would suggest MEF as being probably the most straightforward.
Disadvantages:
Because you need to be generic, it's unlikely you'll be able to use
a particular feature of any one database
It'll take longer because for each feature you develop, you need to write the code in the DAL for it, and then write the code for each separate database assembly, plus any SQL coding in the database itself, and then test it for each database.
Another approach to solve this problem would be to use the SQL Server as the layer that ties together the different databases. SQL Server 2005 and later have a feature called Linked Servers. This will let you link to other database.
This approach will allow you to model you datalayer as if it was one database and let SQL Server abstract the complexities of the multiple databases.
You can also look at the SQL Server feature called OPENROWSET. This will allow you to query other databases with out setting up the linked servers.
Yes, it's feasible. You'll need a connection string for each database type (and catalog) in your web.config and you may need to install different drivers on your server (like the ODBC driver).
The only disadvantage I can think of off the top of my head is you won't be able to easily join tables between databases. If you ever have to do that, you'll need to select from the individual database tables and either:
loop through the tables in your code-behind and manually process the data like a join would.
or insert the selected tables into a temporary table on one of the databases and then use that server to do the join .
Related
I need to pull data from a single table stored in a MSSQL database. The data then gets stored in a staging table in AX, from where it is processed according to the business logic.
Performance is a key factor in this project.
Now I was doing some research of what are the possibilities to retrieve data from an MSSQL database with X++ code and found following blog:
Connecting to Databases through X++
Basically there are different ways which can be used for this endeavour:
ODBC - Open Data Base Connectivity
OLEDB - Object Linking and Embedding
ADO - ActiveX Data Objects
Connection Class
Now I was hoping that someone could give input of which one is preferrable and why (especially in regards to performance).
Any input is appreciated.
The connection class isn't a valid option because it connects to the same database AX is connected to, so your choices boil down to ODBC, OLEDB and the ADO/.NET way.
Personally I would go for the .NET integrated way (called OleDB in your link) but would use System.Data.SqlClient instead of System.Data.OleDb because it's natively written in .NET. If your code is compiled to CIL that should give you best results.
No matter what option for the retrieval you pick, you should really be building a recordinsertlist and perform a set based insert instead to optimize insert performance.
This sounds like a job for the Data Import/Export framework within Ax 2012.
In my new work, they have two ASP.net projects. Both projects are using the same MS SQL Database. Each project has a different developing team and end users. And each project has its own tables, and there are a common tables which both projects reads/writes data, and sometimes they use this common tables to send information to each other. i.e one system insert record, the other system update a flag in this record which means 'Yeah I can see it', and update some fields, then the first system catch the data ... etc.
My first question: Is this a good design, what are the disadvantages ?
In the other hand my opinion to split the database into two databases, one for each project, and make communications between them be through web services.
My second question: which approach is the best practice, and why ?
I do not think there is any problem of having two different projects sharing a common database.
Instead of splitting database into two separate databases , I would suggest have single database only and create a third separate WCF project.
This WCF project will have only one purpose that is act as database layer , so all the database queries will be written in that service and asp.net projects will consume it.
Advantage of this approach is that all the queries will be centralized and there will not be any duplication of queries.Also in future if any new Module comes in the system like desktop application or Mobile application then there is no need to put large efforts in database queries.
Same queries can be used in all places, so maintenance will be simpler.
I don't think there is any problem with having a database common for two projects.I mean, even in a single project, there are so many users updating the same table at the same time.
don't see major drawbacks to the approach. Personally i would prefer database table prefixing like
project1_sometbale
project2_sometable
common_sometbale
I'd like to know the best architecture.
We have a web application running different domains. Each domain has its own MySQL database but the db structure is the same for all of them.
We have a web application for the visible part of the application.
We have a dataLogic project
We have a dataEntities project
We have a dataAccess that contains only the methods to connect to the data base.
Before we called stored procedures on a database. But we had to change it because the performance was bad. Also, the problem was that every change we made we had in a stored procedure we had to copy to every database.
We are thinking in using a WebService to retrieve the data. Every domain can call the web service with a connection string and connect its database to retrieve data. This way when we change a SQL query we only have to compile the webService and change it, we don't have to change versions on multiples domains.
Also, what do you think about the SQL queries? Since we don't want to keep using stored procedures, what is the best way to do it? Directly from code?
Thanks
T
If you have multiple Database servers you will have to make Structural changes from one DB to another one way or another. There are many tools to change Database structures. These tools will look for differences between Schema, and will either generate the SQL code for you, or do the changes by itself (it depends a lot in the tool, there are powerful ones and not so powerful ones). Please do take a look at Toad for MySql. Now, for the Data changes, you may want to replicate the data from one Database to another. This is done through Replication.
We are thinking in using a WebService to retrieve the data. Every
domain can call the web service with a connection string and connect
its database to retrieve data.
This sounds like a good idea and since you already have "dataAccess" and "dataLogic" projects, it should not be too hard to make the services.
Also, what do you think about the SQL queries? Since we don't want to
keep using stored procedures, what is the best way to do it? Directly
from code?
I don't think it is a good practice to have the SQL queries directly into your code, but it depends in a lot of things, so I would suggest Stored Procedure vs Hard-Coding the queries, or LinQ (Entity Framework 4.1).
Good luck with your project and I will take a look at this thread frequently to see what you end up doing.
Have fun!
Hanlet
Environment:
ASP.Net 4.0
MVC 4
SQL Server 2005
Visual Studio 2010
Issue:
We have an SQL 2005 Database which is transactionally replicated to a separate server because a number of large business queries are run against the data and slow the system down. The secondary server is used for all reports (read only), while the primary server is used for day-to-day business. Our legacy code uses stored procedures to access the database and it was relatively easy to maintain different connection strings and have all reports use the report server connection string. We've recently started writing all of our newer code using Entity Framework for data access, however, and I'm at a loss for how to deal with the two different servers.
A simple solution would be, perhaps, to simply maintain two .edmx and point all of the reports to the second .edmx. I strongly dislike this method, however, as it requires that the developers maintain the two different files.
Has anyone else encountered this scenario and devised a more appropriate solution? Is there any way I can use the same .edmx for both servers (since they are identical) but somehow specify at the Controller or Action level which connection string to use?
Ideally I am looking for a solution that does not require manual SSDL writing. I'd like to continue to use the designer and "Update Model from Database" features.
Thank you for your time,
Mirzero
When creating the EntityContext object you can specify a connection string in the constructor. So you would just need to pass the required string to the method creating the EntityContext instance.
I have ASP.NET project and I want to know what is better to use.
ODBC connection and with Server Explorer (drag and drop make DataSet and modify it) or do some DBconnect class with connection to database, queries and use it for GridView?
When I use server explorer, I don't have good feeling because all logic is on aspx page and I do not separate from the application layer logic layer.
It will be a lagre application, databese(PostreSQL) have 18 tables and difficult constraints and application have to generate some documents etc. .
"Better" depends entirely on your situation. Is the purpose to get something done as quickly as possible for internal users at your company, or is this going to be a commercial site that will need to be highly extensible and needs to be as easy as possible to maintain? Will you need to integrate with other platforms possibly built using other languages at some point? The answers to all of these questions should affect your decision.
If you're looking to separate your project into distinct layers, then I would recommend an ORM such as NHibernate or Entity Framework (there are other commercially available ORM products out there, but these are the ones I'm familiar with and which you can easily get help with on this site).
Create a DataSource with LINQ to Entity. It let you the liberty of LINQ with the peace of mind of when you change something il will break your build so you will be able to debug more efficiently.
Well if you have total flexibility, I would recommend using C# ASP.NET 4 with MVC3 razor for the UI and application code. Use Entity Framework 4.1 code first for the data access layer.
This way you will always work with real objects that you create, and with List<realtype> instead of the total mess that exists with datasets.