I've created the Entity-relationship model of my database and the I normalized it, but I've a issue, I don't know if after of the normalization I've to create new relations between news tables derived from normalization and the original tables or not.
When you say "relations", you mean constraints, correct? :-) Normalizing a relational database means you broke the tables up to reduce redundancy and dependency. If you are making more tables, then yes you need to create new constraints (keys). You'll also need to run a conversion on your database to move the data to the new tables appropriately.
Related
I'm dealing with a huge ERP database, hundreds of tables, and am having trouble figuring out how one entity is referenced from another. Let's call them the "sale" table and the "shipment" table. Each has FK relationships with numerous other tables, but no FK links either one to the other, and no obvious associative table is linked to both.
Is there any good way using SQL or the psql command line to discover the chains of relationships that connect the two tables?
Is there any good way to discover the chains that connect a specific row or PK of "sale" and a specific row/PK of "shipment"?
You should look at a tool like schemacrawler. It's good a opensource tool for data modelling retro-engineering.
You can find documentation here.
I have never done a conversion from a relational database to a data warehouse before. I have the data warehouse tables and models created and am currently creating staging tables. How do I go about actually populating the data warehouse tables? For instance, I am populating a portion of a fact table. However, a primary key cannot contain any null data, so I violate that constraint by transferring data over. I'm assuming primary and foreign key constraints are created prior to migration. Is this correct? Any help is a appreciated, I may be missing some simple database logic here.
You can remove constraint while you waiting for some data or remove it at all and add it only in daily tests to be sure that data valid.
I'm creating a new visual studio web site using MVC4/webapi that will go against a database of 75 preexisting tables (not perfect in terms of foreign keys, etc.). I'm thinking that I will create an ado.net entity data model and select all my tables. then, when my tables change I will do the "update model".
With my linq2sql projects, I always ran sqlmetal against all my tables all the time to keep things in sync and that worked fairly well.
Is my plan to have all my tables in one ado.net entity data model reasonable? what pitfalls might I run into? Is it better to have lots of ado.net entity data models? I've tried having multiple ado.net entity models in other projects and I seem to constantly be getting my connection strings doubled in my web.config.
I did do a search on SO and did not find any discussions that directly addressed my concern.
If you followed your plan, you would miss out on an opportunity to have an entity model simpler than your database model:
Your application almost certainly doesn't need all 75 tables.
You would be missing the opportunity to consider a series of 1-1 tables as a single entity
You would be missing the opportunity to use inheritance in your model
You would be missing the opportunity to keep junction tables out of your model
You would be losing one of the greatest advantages of Entity Framework over LINQ to SQL: it does not need to stay one-to-one with the database.
What is database schema decomposition?
Why do we need decompositions?
Probably what is meant by this is that you start with one general schema for your database and decompose this into more specific schemas.
A good choice of more specific schemas can be determined using FK constraints defined on the schema, like join dependencies etc.
Why do you need it? I believe it significantly helps with normalization and manageability.
I am working on an old database, that i do not want to touch or modify in any way if possible.
I want to build a new application that uses it's data but the database has no actual relations despite having primary and foreign keys linking tables.
If i import these tables into an Entity Framework model and add the associations manually, will i be able to use things such as lazy loading and linq?
Many thanks,
Kohan
This is definitely possible. Entity Framework simply generates SQL queries containing joins or where clauses that reference columns that you define in your conceptual model as foreign keys. The generated SQL is directly executed by the database.
Primary and foreign keys are only in your database for referential integrity. As a very simple test you can execute a SQL statement directly in your database that joins two related tables that do not have a foreign key relationship. You'll see that the query simply works. Entity Framework does exactly the same when you correctly define the relationships in your model.