I developed a web application running on MySQL and now I need to get some data from another database (Microsoft SQL Server).
The SQL Server administrator creates a view to give me the data I need. Now the question is:
How can I work with this data on my current Symfony2 application?. This data will be only read only data, but eventually I´ll record some of this data on MySQL.
Do I need to develop another app, in python for example, to extract that SQL Server view data and save them into MySQL table?
It doesn't matter for Doctrine that your entities refer to a view or a real table, so declare the entity of view like other entities and use it as you want for queries, relations with other entities, etw.
Related
I am researching my first RESTful API project to interact with the automation side of our ERP system.
I am planning a SPA like here
The simple web page is to provide users with a list of purchase requisitions they must approve or decline.
The app will retrieve the data from a SQL Server view into a collection. As the user approves or declines the requisition this is recorded in the object and when the User presses 'Update ERP' the app will build a XML list of the collection and using a SQL Server stored procedure insert it into the SQL database of the ERP for the automation process to pick up and process
I have three questions
The examples uses SQL Server tables in EF should I build the view in the "model" (some how!) or can I use my SQL Server view?
If I use my SQL Server view, does it need an ID / unique key column (for example row number) to make EF work better?
Would be better using a C# class to do the data retrieval and sending the xml data into the database with SQL Server stored procedure than EF?
The exampe uses SQL tables in EF should I build the view in the
"model" (some how!) or can I use my SQL view?
Use the "Code First to an Existing Database" workflow, and you can select the views from the database, and EF will generate the classes.
If I use my SQL view does it need an ID/ unique key column (for
example row number) to make EF work better?
EF will try to identify the key columns, but it's not very smart about it. You can change the model after the initial generation. The key doesn't matter very much if you don't update the entities, but every Entity still needs a key.
Would be better using a C# class to do the data retrieval and sending
the xml data into the database with SQL stored procedure than EF?
No I would use EF for the retrieval, but probably straight ADO.NET to call the stored procedure.
In Oracle EBS, when we are doing data conversions and interfaces, loading data into Oracle from another system, how do we make sure the record is being locked? How do we make sure no other person is updating our records?
Oracle EBS seeded API's will take care about locking. We don't insert data into EBS base tables directly,
validate the data and insert into interface tables later we run oracle standard programs to import interface tables data into base tables.
These oracle standard programs use oracle seeded API to insert data into multiple base tables.
How do we make sure no other person is updating our records?
Developers use their own custom staging tables to import data into EBS.
when data upload staging tables to interface table maintain each interface data source is different, usually other persons don't update other interfaces records, We can't track if anyone updated from database backend tools like sql developer or TOAD. we can track transaction from last updated by column if they update from applications
If you have any specific issue related locking let us know
I am new to Oracle database and I wanted to create a database in Oracle. I followed this link to create a database:
http://www.fehily.com/books/createdb/createdb_oracle_11g_2.html
In Microsoft SQL Server, when we create a database, we use the create database command and the database creation is instantaneous [within fraction of seconds], but the Database Tool as described in link above took couple of minutes to create the database. Is database creation in Oracle this much slower?
Searching more about it, I have a feeling that this database created using above tool in Oracle is not equivalent to the database we create in SQL Server. Rather, the schema/user in oracle is appearing to be equivalent to database in SQL Server. Is it true?
So, If I want multiple databases in Oracle, do I create a single database and then multiple schemas inside that single database? And then are those multiple Schemas are my databases?
I am very much confused about all this. Can someone please refer me to a nice article/book that explains these things in oracle in detail?
For most purposes, yes you would indeed map a SQL server database to an Oracle schema (=user).
The term "database" in Oracle does not mean the same as in SQL Server. An Oracle "database" (from a technical point of view) is more like a SQL Server instance/installation, rather than a "database" in SQL Server.
SQL Server has two levels of namespace: database and schema. Whereas Oracle only has a single level of namespaces: a schema (which has a 1:1 relation to a user)
SQL Server and Oracle both support Schema.
A Schema is like a new database but it is not a new database
Maybe you are confused, Mysql doesn't support schemas but SQL server offers full support for it.
In mysql your database is a schema, to only difference is that it doesn't support multi schemas
For the part of creating multi databases or a single database if multiple schemas it all depend in your specific situation, you should test thinks like performance and how much money you want to spend, a multi database approach can be very expensive unlike a multi Schema approach
I want to create a new project on contract management system. In this I have to manage multiple organizations and want to create new instance in sql server dynamically for each organization in a saas environment. How is this posiible? I am using asp.net for development. Any help would be appreciated.
A true SaaS application has a single application and database. It has the ability to have multiple tenants use the application. All data in the database needs to know what tenant it belongs too.
For instance if you have a booking system: Your customers sign up to use the software and become a row in the customer table with an ID. When a booking is made it has a customerID column as a foreign key to the customer table. Then all reports, booking views etc are done for that tenant using their customer id. You as a service provider can then run reports on all customers/tenants for your own purposes. Multiple tenants can use the system and all their data be in the same set of tables. This then means when you need to cluster replicate backup etc it is a single db, and a single migration for schema updates.
See these wiki's on multitenancy and SaaS
This of course requires your DB schema (and your app) to support this - if you are unable to change the schema then there are a number of options to up a new DB based upon the technology you are using. If you are using code first EF, then there will be db creation and migration scripts you can use. Otherwise it may justhave to be a sql script you have to generate and then maintain and run this each time a new customer is required. Personally i would rather have a single DB with an appropriate schema.
We are going to be selling a service that will be hosted by us, and each client we host will have their own database, but there will be one centralized website. I currently have a blank database with the few things that a new client will need. What is the best way to copy this database so I can setup another client? I want to be able to do this from an .aspx page. Thanks in advance!
Update:
By .aspx page, I just meant that I need to be able to kick off the process from an .aspx page.
Update2:
We're running SQL Server 2008.
Update 3: Referencing Cade Roux's answer... Thanks for a great answer, but...
What is the reason for merging all of the databases into one, and then distinguishing clients based on an identifier in each table? Wouldn't this greatly complicate the architecture of the entire product? I would need to add these Client ID columns to practically every table, and the DAL would need to know which client data its looking for. With the current setup I have, I just switch out the connection string in the DAL, depending on which user is accessing the site. That way, after the connection string is set, I never need to worry about finding client specific data! How do these approaches compare (and should I add this as a separate question?
You have a few different options:
You can detach your empty database, then when a user signs up, copy that database and mount it under a unique name for them and map it to their account in your master database, say.
You can create a database from scratch using scripts and populate any base data either from an online template database or scripting the base data and map it to their account in your master database.
You should seriously consider going to a multi-tenant architecture where all users are in the same database (with most tables having CustomerID columns to segregate the data) if you are going to have more than a few dozen customers.
Regarding your notes about option 3 - it depends on your application. Multi-tenant can be difficult to retrofit. On the other hand, managing and upgrading hundreds of individual customer databases can be difficult in the long haul.
There are previous Stack Overflow questions regarding this:
What are the advantages of using a single database for EACH client?
One database or many?
I think I'll see about re-tagging them with multi-tenant-db or something. Anyhow, I think that this comes up as a consideration secondary to your answer about a particular tactic does show the importance of including details about your overall goals in strategy in every question on StackOverflow.
Depending on what database you're using, there are several approaches. The simplest is to ask your database software to generate SQL code for creating the database and include that with your software. Another would be to just script out in C#/VB the steps needed to recreate your empty database.
Why the need for .aspx page?
You don't say what db version you're using but in SQL2005-2008, you have the ability to "script database as" and then "create to" and have it port the sql to a query window. You could then work with that to create a stored procedure that can be called from your .aspx page.
SQL Server has a system database called 'model'. Any database objects (tables, views, stored procedures) that exist in the model are added to any new database created.
You could create your 'client database' schema as model, and any new database would have all the same tables...
But, if you need to change your database schema later, your best option is to write change scripts which are part of your code-behind file. Since changes to the 'model' database are not propagated to existing databases, the application needs to detect and upgrade the database schema as necessary.
Disadvantage to this approach: If you want a database which isn't a 'client database' then you would need to create the database, and then delete the 'client database' tables.