I know asp.net with mySQL is possible, but does it work well (fast and stable)? I am looking at a project for a client, they want to stay on mySQL, but they like they idea of going to asp.net from PHP. I can give them a better price by far in asp.net (more productive for me) and keep the project within their budget.
BUT, am I going to run into a whole lot of little 'gotchas' dealing with a mySQL DB instead of the SQl Server DB that I am used to?
Looking for advice from people who have actual done projects using these two together...either successfully, or unsuccessfully.
Seriously, man, I wouldnt try to over complicate it. Write the site just like you normally would, but using the MySQL data provider instead of the mssql provider. Keep it simple. Now there are some differences in how the two DBMSs handle their SQL.
Here are items that tripped me up originally.
MSSQL: SELECT TOP 5 * FROM Table
MySQL: SELECT * FROM TABLE LIMIT 0,5
MSSQL: SELECT IsNull(NumberField,0) FROM Table
MySQL: SELECT IfNull(NumberField,0) FROM TABLE
MySQL: Everything is CaSe-SenSiTivE
MySQL: Has stored procedures, but they are not as user friendly as MSSQL, so stick with inline sql.
MSSQL: select * from table where column1 = #col1 and column2 = #col2
MySQL: select * from table where column1 = ? and column2 = ? (remember to specify your command parameters in order)
There are a bunch of other little things that may complicate or confuse, but thats what this site is for, so you can ask
I would suggest using a tool like iBATIS.NET. It's a data mapping tool that works very well with .NET, and it's very easy to learn and is highly configurable.
You can configure multiple database providers (MySQL, SQL Server, Oracle, Sybase, etc.); almost everything is XML configurable, so SQL can be edited while your app is running, and if at some point they want to switch backend DBs, it's (sometimes) as easy as changing a couple of settings in an XML file.
Check it out: http://ibatis.apache.org/overview.html
There is a third option, MSSQL <-> SSIS/DTS <-> MySQL.
Both parties get to stay in their respective comfort zones, and you'll be more productive instead of tearing hair out working around gotchas.
Related
I started to use Flyway in my current project for database migrations and I like it very much. I currently use Oracle in PROD- and Derby in TEST-Environment.
Pretty soon, I did run in the problem of database specific sql commands, e.g.
ALTER TABLE T1 MODIFY F1 VARCHAR(256); on Oracle vs
ALTER TABLE T1 ALTER F1 SET DATA TYPE VARCHAR(256); on Derby.
I can't see a way to write a "vendor neutral alter table modify column datatype" sql.
What's the best way to deal with this problem using Flyway?
You can use the flyway.locations property.
In test in would look like this:
flyway.locations=sql/common,sql/derby
and in prod:
flyway.locations=sql/common,sql/oracle
You could then have the common statements (V1__Create_table.sql) in common and different copies of the DB-specific statements (V2__Alter_table.sql) in the db-specific locations.
An even better solution, in my opinion, is to have the same DB in prod and test. Yes, you do lose a bit of performance, but on the other hand you also eliminate another difference (and potential source of errors) between the environments.
The differences in SQL between Oracle and some of these desktop databases is minor. Is it possible for a developer to insert custom code to do some light-weight dynamic stripping of the SQL at runtime based on the environment (e.g. remove tablespace designation)?
I prefer this approach to relying on each developer to manually keep two sets of SQL in sync.
I have to add globalization (Arabic) to my English ASP.NET application.
It's been so easy to get information about the changes to be done in Visual Studio but not as easy to get information about general lines to follow (server, database, etc) and specially the changes to do in my SQL Server database. Do I need to duplicate the database? Maybe the tables?
The application is a Learning Management System: users that watch a flash movie and then they do an exam and after it they write comments and feedback. Tables are User, Organisation, Presentation, Movies, Feedback and History, plus a couple more for security.
Our idea is keep one server if it's possible but duplicate databases is allowed (I don't know if that would be an acceptable solution).
How should I proceed?
Thanks very much in advance, any help is really appreciated.
For the web application, there are a couple ways to handle localization, but you'll end up with resource files (.resx).
On the database side, decide if you only have 2 languages to support, in which case you may be able to get away with duplicating text field, or if there's the possibility of other languages, in which case you would want to have a separate table for text values, joined with a language key.
For example:
table something
pk id,
string data,
etc
table something_resx
pk id,
fk something_id
fk lang
string text
Then you'd have a query like
select data, text from something s
join something_resx r on s.id = r.something_id
where lang = lang_key
I don't know what sort of application you have, but if at all feasible I would advise that you take the localization concern entirely away from the data layer. Of course if your app is content-centric (such as a e-commerce site) it's not feasible. But if your DB only contains a few language-specific things such as country names (for example), then you could remove these and move the localization responsibility to the application layer (to keep with this example, replace the country names in your database with an ISO code, and let the application's presentation layer translate these into country names).
This is because localizing an app can depend on the localization support given to you by the .NET Framework and Visual Studio (resources files, satellite assemblies, language fallback) and many tools will help the process. At the database layer, however, you are left on your own to do everything.
I am currently developing an application that will store data in an SQLite database. The database will have much more read- than write-access (in fact, it will be filled with data once, and then almost only reading will happen). The read-performance is therefore much mre important. The schema I am currently developing is very likely to change in the future, with additional columns and tables being added. I do not have very much experience with databases in general. My question is, specifically in SQLite, are there any pitfalls to be considered when changing a schema? Are there any patterns or best practices to plan ahead for such cases?
Here are some suggestions:
Don't use select * from ... because the meaning of * changes with schema changes; explicitly name the columns your query uses
Keep the schema version number in the database and keep code in the application to convert from schema version N to version N+1; then all the code in the application works with the latest schema version; this may mean having default values to fill added columns
You can avoid copying tables for schema updates with SQLite version 3.1.3 or better which supports ALTER TABLE ADD COLUMN...
Look into data-marts and star schema design. This might be overkill for your situation, but at least it will prevent you from designing at random.
I'm currently looking at a terrible legacy ColdFusion app written with very few stored procedures and lots of nasty inline SQL statements (it has a similarly bad database too).
Does anyone know of any app which could be used to search the files of the app picking out any SQL statements and listing the tables/stored procedures which are referenced?
Dreamweaver will allow you to search the code of the entire site. If the site is setup properly including the RDS password and provide a data source it can tell you a lot of information. I've only set it up once so I can't remember exactly what information it gives you, I think maybe just the DB structure. Application window > databases. Even if it isn't set up properly just searching for "cfquery" will quickly find all your queries.
You could also write a CF script using CFDirectory/CFFile to loop the .cfm files and parse everything between cfquery and /cfquery tags.
CFBuilder may have some features like that but I'm not to familiar with it yet.
edit I've heard that CFBuilder can't natively find all your cfqueries that don't have cfqueryparam but you can use CF to extend CFB to do so. I imagine you could find/write something for CFB to help you with your problem.
another edit
I know it isn't indexing the contents of the query, but you can use regex to search using the editor as well. searching for <cfquery.+(select|insert|update|delete) checking the regex box should find the queries that aren't using cfstoredProc (be sure to uncheck the match case option if there is one). I know Dreamweaver and Eclipse can both search for Regex.
HTH
As mentioned above I would try a grep with a regex looking for
"<cfquery*" "</cfquery>" and "<cfstoredproc*" "</cfstoredproc>"
In addition if you have tests that have good code coverage or even just feel like the app is fully exercised in production you could try turning on "Log Database Calls" in Admin - > Datasources or maybe even at the JDBC driver level, just monitor performance to make sure it does not slow the site down unacceptably.
In short: no. You'd have to do alot of tricky parsing to make sure you get all the SQL. And because you can glob SQL together from lots of strings, you'll almost always miss some of it.
The best you're likely to do will be a case insensitive grep for "SELECT|INSERT|UPDATE|DELETE" and then manually pulling out the table names.
Depending on how the code is structured, you might be able to get the table names by regexing the SQL from clause. But that's not foolproof. Alot of people use string concatenation to build SQL statements. This is bad because it can introduce SQL injection attacks, and it also make this particular problem harder.
I am playing with a CAD application using MFC. I was thinking it would be nice to save the document (model) as an SQLite database.
Advantages:
I avoid file format changes (SQLite takes care of that)
Free query engine
Undo stack is simplified (table name, column name, new value
and so on...)
Opinions?
This is a fine idea. Sqlite is very pleasant to work with!
But remember the old truism (I can't get an authoritative answer from Google about where it originally is from) that storing your data in a relational database is like parking your car by driving it into the garage, disassembling it, and putting each piece into a labeled cabinet.
Geometric data, consisting of points and lines and segments that refer to each other by name, is a good candidate for storing in database tables. But when you start having composite objects, with a heirarchy of subcomponents, it might require a lot less code just to use serialization and store/load the model with a single call.
So that would be a fine idea too.
But serialization in MFC is not nearly as much of a win as it is in, say, C#, so on balance I would go ahead and use SQL.
This is a great idea but before you start I have a few recommendations:
Be careful that each database is uniquely identifiable in some way besides file name such as having a table that describes the file within the database.
Take a look at some of the MFC based examples and wrappers already available before creating your own. The ones I have seen had borrowed on each to create a better result. Google: MFC SQLite Wrapper.
Using SQLite database is also useful for maintaining state. Think ahead about how you would manage keeping in mind what features are included and are missing in SQLite.
You can also think now about how you may extend your application to the web by making sure your database table structure is easily exportable to other SQL database systems- as well as easy enough to extend to a backup system.