Entity Framework expose several databases as a whole - sql-server-2008

I have three databases with exactly the same schema (SAP Business One databases). In this databases I have an item masters table connected to a warehouse stock table via the item code. Can I have just one Entity framework model that has only one item master object and one warehouse stocks object which draws data from the 3 databases?
The items are the same in the three databases but they have different warehouse codes.
I don't know if I have made myself clear.

If you want single EF model which will simultaneously load data from three databases then answer is no. If you want single EF model which can be used for all three databases the answer is yes but all your databases must use same database provider (server) and must have exactly the same schema of mapped tables.
The whole magic in this case is in connection string which can connect only to single database and cross database calls are not allowed.
If you need the first scenario you can try to hide unions and cross database queries in views and map those views in your model. This have two disadvantages:
Relation between views are not allowed in SQL Server but you can create the relation in EF model
Views are read only in EF model. If you want to modify data the best way is mapping stored procedures which will do that.

Related

is it enogh to have a single database for the entire software or any application like (if i am using MS Access database in my software)

I'm designing a database and I have a query about how to structure tables in Microsoft Access.
I'm not sure if I should create a new database for each table I create, or put all of my tables into one database.
Here are examples of the tables I require:
employee_info data
machine info
billing
A single database can have multiple tables amd you can use multiple applications. There is no sense in creating multiple databases for multiple tables.

Querying data from 2 MySQL Databases to a new MySQL database

I want to query data from two different MySQL databases to a new MySQL database.
I have two databases with a lot of irrelevant data and I want to create what can be seen as a data warehouse where only relevent data should be present coming from the two databases.
As of now all data gets sent to the two old databases, however I would like to have scheduled updating so the new database is up to speed. There is a key between the two databases so in best case I would like all data to be present in one table however this is not crucial.
I have done similar work with Logstash and ES, however I do not know how to do it when it comes to MySQL.
Best way to do that is create a ETL process with Pentaho Data Integrator or any ETL tool. Where your source will be two different databases, in the transformation part you can remove or add any business logic then load those data into new database.
If you create this ETL you can schedule it once a day so that your database will be up to date.
If you want to do this without an ETL than your database must be in same host. Than you can just add database name just before table name in query. like SELECT * FROM database.table_name

Persisting Entities Mapped to MySQL View in JPA/Hibernate

I have a entity Customer, which is mapped to a view which is defined as a series of joins between Customer, Account, and Person in my database.
I am using JSF 2.0 with JPA set up with Hibernate. The backing database is MySQL
My question is that given the fact that my Customer entity is mapped to a database view, how will this complicate persisting of new Customer entities?
I quote from Adam Bien's book :
"For SQL queries there is no difference between views and tables, so you can easily map a JPA entity to a view transparently. The code on the Java side remains clean and simple – and you will even get better performance. There is a drawback: not all views are updatable. Whether a view is updatable or not highly depends on the complexity and particular database. E.g. in Derby DB all views are not updatable."
http://www.dzone.com/links/r/mapping_jpa_entities_to_sql_views_it_works_even_w.html

Difference Between Schema / Database in MySQL

Is there a difference between a schema and a database in MySQL? In SQL Server, a database is a higher level container in relation to a schema.
I read that Create Schema and Create Database do essentially the same thing in MySQL, which leads me to believe that schemas and databases are different words for the same objects.
As defined in the MySQL Glossary:
In MySQL, physically, a schema is synonymous with a database. You can substitute the keyword SCHEMA instead of DATABASE in MySQL SQL syntax, for example using CREATE SCHEMA instead of CREATE DATABASE.
Some other database products draw a distinction. For example, in the Oracle Database product, a schema represents only a part of a database: the tables and other objects owned by a single user.
Depends on the database server. MySQL doesn't care, its basically the same thing.
Oracle, DB2, and other enterprise level database solutions make a distinction. Usually a schema is a collection of tables and a Database is a collection of schemas.
Refering to MySql documentation,
CREATE DATABASE creates a database with the given name. To use this
statement, you need the CREATE privilege for the database. CREATE
SCHEMA is a synonym for CREATE DATABASE as of MySQL 5.0.2.
PostgreSQL supports schemas, which is a subset of a database:
https://www.postgresql.org/docs/current/static/ddl-schemas.html
A database contains one or more named schemas, which in turn contain
tables. Schemas also contain other kinds of named objects, including
data types, functions, and operators. The same object name can be used
in different schemas without conflict; for example, both schema1 and
myschema can contain tables named mytable. Unlike databases, schemas
are not rigidly separated: a user can access objects in any of the
schemas in the database they are connected to, if they have privileges
to do so.
Schemas are analogous to directories at the operating system level, except that schemas cannot be nested.
In my humble opinion, MySQL is not a reference database. You should never quote MySQL for an explanation. MySQL implements non-standard SQL and sometimes claims features that it does not support. For example, in MySQL, CREATE schema will only create a DATABASE. It is truely misleading users.
This kind of vocabulary is called "MySQLism" by DBAs.
in MySQL schema is synonym of database.
Its quite confusing for beginner people who jump to MySQL and very first day find the word schema, so guys nothing to worry as both are same.
When you are starting MySQL for the first time you need to create a database (like any other database system) to work with so you can CREATE SCHEMA which is nothing but CREATE DATABASE
In some other database system schema represents a part of database or a collection of Tables, and collection of schema is a database.
Yes, people use these terms interchangeably with regard to MySQL. Though oftentimes you will hear people inappropriately refer to the entire database server as the database.
Simply if you are thinking or discussing about Mysql. Then take a simple answer
"SCHEMA & DATABASE are exactly the same thing, just a synthetic
sugar in mysql."
Just add some more info:
MongoDB also distinguish schema from database.
schema represent the tables, which means the structure of database.
Microsoft SQL Server for instance, Schemas refer to a single user and is another level of a container in the order of indicating the server, database, schema, tables, and objects.
For example, when you are intending to update dbo.table_a and the syntax isn't full qualified such as
UPDATE table.a the DBMS can't decide to use the intended table. Essentially by default the DBMS will utilize myuser.table_a
not like Postgres, SQL server schema is set of database have same thing
but in mysql schema and database it is the same
MySQL does not support the concept of schema. In MySQL, schema and schemas are synonyms for database and databases.
When a user connects to MySQL, they don't connect to a specific database. Instead, they can access any table they have permissions for

What is the difference in View and EER Diagram?

I quite confuse with both. First, both might seen the same. May I know how the View and EER Diagram is apply?
View is a stored query accessible as a virtual table composed of the result set of a query. View is the perspective on the data from tables. It actually does not store data in it but give you the access like tables from the database only thing is you may not allow to insert data in to it.
EER/ER is nothing but data modelling techniques of the database. It is not acting on data but on the structure of tables in database. Generally it gives snapshot of tables & their relation. This is helpful to get the idea that howz the data flows in a database.