I read somewhere that 1NF - 3NF deal with functional dependency, and that the Higher Normal Forms focus on another aspect of database relationships, but I can't remember what. Does anyone know the answer to this?
1NF - 3NF deal with function dependency. BCNF - 5NF deal with ______?
My best educated guess is non-tivial / multivalued dependencies.
Is that correct, or am I way off base?
BCNF deals with functional dependencies.
4NF deals with multivalued dependencies.
5NF deals with join dependencies. 6NF deals with join dependencies in a more general way.
Related
I am learning the functional dependencies concept in IIT lectures.
In that lecture they said there are three types of functional dependencies. They are
Trivial functional dependency
Augmented Functional dependency
Transitive functional dependency
I know how to find the functional dependency. But I don't know that functional dependency is which type.
Please explain with examples for the functional dependency types.
Trivial functional dependency is easiest to understand.
A functional dependency A1A2....An->B
is said to be trivial if B is one of A’s.
To make it non-trivial just remove from the right side of an FD those attributes that appear on the left. (trivial dependency rule)
Augmented functional dependency is basically
when X->Y holds and W is a set of attributes, then WX->WY also holds.
Let me clarify the above two a bit more.
Given a dependency A1A2....Am->B1B2....Bn we can say it is:
Trivial if the B's are subset of A's.
Augmented(or maybe non-trivial) if at least one of the B's is not among the A's
Completely non-trivial if none of the B’s is also one of the A’s
3. Transitive functional dependency can occur only in a relation that has 3 or more attributes.Let A, B, and C designate three distinct attributes (or distinct collections of attributes) in the relation. Then given A->B and B->C then A->C is a transitive functional dependency.
Whenever a proper ER diagram is drawn for a database and then mapped to the relational schema, I was informed that it guarantees 3NF.
Is this claim true?
If not, can anyone provide me a counter example.
Also, please tell me whether any normal form can be claimed to be strictly followed when relational schema is mapped from a perfect ER diagram?
The short answer is no. Depending on the analysis and design approach there could be examples of ER models that appear perfectly sound in ER terms but don't necessarily translate to a relational schema in 3NF. ER modelling and notation is not really expressive enough or formal enough to guarantee that all functional dependencies are correctly enforced in database designs. Experienced database designers are conscious of this and apply other techniques to come up with the "proper" design.
Terry Halpin devised a formal method for database design that guarantees a relational schema satisfying 5th Normal Form (see orm.net). He uses the Object Role Modelling approach, not ER modelling.
The diagram just shows what entities and attributes you have and how entities relate to one-another. Your attributes can violate the normal forms. An ER diagram is just a representation, it does not enforce any rules.
There is nothing about representing a model in an ER diagram that implies satisfaction of 3NF.
The thinking behind the erroneous claim may be based on the idea that when you, for example, convert a repeating group from columns to rows in a child table, or remove partially dependent columns to another table, you are increasing the normal form of your relations. However, the diagrammatic convention doesn't enforce this in any way.
Let's see an example (in oracle):
CREATE TABLE STUDENT (
ID INTEGER PRIMARY KEY,
NAME VARCHAR2(64) NOT NULL,
RESIDENCE_STREET VARCHAR2(64),
RESIDENCE_CITY VARCHAR2(64),
RESIDENCE_PROVINCE VARCHAR2(64),
RESIDENCE_POSTALCODE NUMBER(8)
);
In some countries postal code uses prefixes to identify the region or province, so RESIDENCE_PROVINCE has a functional dependency from RESIDENCE_POSTALCODE. But RESIDENCE_POSTALCODE is a non-prime attribute. Then this easy and common example is "legal" and it is not in 3NF.
I understand that at least EF 6 supports multiple DbContexts. This can be used to model BoundedContext. I did some google searches but could not find a definitive answer to this question. Is it advisable to use different db schemas for different DbContexts/BoundedContext? I know that ORMs abstract away the persistence mechanisms but I personally can see parallels between shemas and ddd/ef contexts.
It is a possibility. As with most architectural questions, the answer is: it depends.
In this case, it depends on how your overall architecture is and how your bounded contexts are structured. If they have similar aggregates that are persisted to the same tables (that is, they're different because of the context), it might be a good idea to have different DbContexts because then you can evolve them separately.
Note though that you may be introducing hidden constraints and dependencies between your bounded contexts.
If your bounded contexts have very different aggregates, then there's no need to use different DbContexts and you can just share the same one.
Another option you might consider, is using a different DbContext for reading and writing. It also allows you to evolve your model separately. (that's more of a CQRS approach though)
Are there examples of Relational tables which are in 3NF or 4NF but
not in Domain Key Normal Form?
Edit, Aug 2018 after 9 years
DKNF is the ultimate state of database normalisation after all previous normal forms have been eliminated
1NF -> 2NF -> 3NF -> BCNF -> 4NF -> 5NF -> 6NF/DKNF
The 6NF/DKNF question (Fagin vs Date) is out of scope here
So the question doesn't make sense because any design that is "only" in 3NF or 4NF won't be DKNF (or 6NF)
Most folk don't design past BCNF unless you have particularly complex relationships.
New link: https://www.tutorialride.com/dbms/database-normalization.htm
Yes. Domain Key Normal Form is not an enforceable normalization step. DKNF is "If every table has a single theme, then all functional dependencies will be logical consequences of keys. All data value constraints can then be expressed as domain constraints." In other words, if every constraint on the relation is a logical consequence of the definition of keys and domains, then the relation is in DKNF.
DKNF is mistakenly referred to as Sixth Normal Form (6NF) by some in the research community, but it is technically incorrect. CJ Date covers this in detail, and this On DK/NF Normal Form article is where I first learned about DKNF and understood its properties.
We are developing an extension (in C# .NET env.) for a GIS application, which will has predefined types
for modeling the real world objects, start from GenericObject, and goes to more specific types like Pipe and Road with their detailed properties and methods like BottomOfPipe, Diameter and so on.
Surely, there will be an Object Model, Interfaces, Inheritance and lots of other essential parts in the TypeLibrary, and by now we fixed some of them. But as you may know, designing an Object Model is a very ambiguous work, and (I as much as I know), can be done in many different ways and many different results and weaknesses.
Is there any distinct rules in designing O.M.: the Hierarchy, the way of defining Interfaces, abstract and coclasses enums?
Any suggestion, reference or practice?
A couple of good ones:
SOLID
Single responsibility principle
Open/closed principle
Liskoff substitution principle
Interface segregation principle
Dependency inversion principle
More information and more principles here:
http://mmiika.wordpress.com/oo-design-principles/
Check out Domain-Driven Design: Tackling Complexity in the Heart of Software. I think it will answer your questions.
what they said, plus it looks like you are modeling real-world entities, so:
restrict your object model to exactly match the real-world entities.
You can use inheritance and components to reduce the code/model, but only in ways that make sense with the underlying domain.
For example, a Pipe class with a Diameter property would make sense, while a DiameterizedObject class (with a Diameter property) with a GeometryType property of GeometryType.Pipe would not. Both models could be made to work, but the former clearly corresponds to the problem domain, while the latter implements an artificial (non-real-world) perspective.
One additional clue: you know you've got the model right when you find yourself discovering new features in the code that you didn't plan from the start - they just 'naturally' fall out of the model. For example, your model may have Pipe and Junction classes (as connectivity adapters) sufficient to solve the immediate problem of (say) joining different-diameter pipes to each other and calculating flow rates, maximum pressures, and structural integrity. You later realize that since you modeled the structural and connectivity properties of the Pipes and Junctions accurately (within the requirements of the domain) you can also create a JungleGym object from connected pipes and correctly calculate how much structural load it will bear.
This is an extreme example, but it should get the point across: correct object models support extension and often manifest beneficial unexpected properties and features (not bugs!).
The Liskov Substitution Principle, often expressed in terms of "is-a".
Many examples of OOP would be better off making use of "has-a" (in c++ private inheritance or explicit composition) rather than public inheritance ("is-a")
Getting Inheritance right is hard. Doing so with interfaces (pure virtual classes) is often easier than for base/sub classes
Check out the "principles" of Object oriented design. These have guidelines for all the questions you ask.
References:
"Object oriented software construction" by Robert Martin
http://www.objectmentor.com/resources/publishedArticles.html
Checkout the "Design Principles" articles at the above site. They are the best references available.
"BottomOfPipe"? Is that another way of saying the depth of the Pipe below the Road?
Any kind of design is difficult and can be done different ways. There are no guarantees that your design will work when you create it.
The advantage that people who design ball bearings and such have is many more years of experience and data to determine what works and what does not. Software doesn't have as much time or hard data.
Here's some advice:
Inheritance means IS-A. If that doesn't hold, don't use inheritance.
A deep hierarchy is probably a sign of trouble.
From Scott Meyers: Make non-leaf classes interfaces or abstract.
Prefer composition to inheritance.