Difference between 3NF and BCNF in simple terms (must be able to explain to an 8-year old)

Your pizza can have exactly three topping types: one type of cheese one type of meat one type of vegetable So we order two pizzas and choose the following toppings: Pizza Topping Topping Type ——– ———- ————- 1 mozzarella cheese 1 pepperoni meat 1 olives vegetable 2 mozzarella meat 2 sausage cheese 2 peppers vegetable … Read more

SQL: Creating a Relational table with 2 different auto_increment

1 Concept You have misunderstood some basic concepts, and the difficulties result from that. We have to address the concepts first, not the problem as you perceive it, and consequently, your problem will disappear. auto incremented IDs, which are of course primary keys. No, they are not. That is a common misconception. And problems are … Read more

Sql – Indirect Foreign Key

You should always enforce referential integrity by using “normal” FOREIGN KEYs. In a nutshell, FOREIGN KEYs have the following advantages: They are already implemented within the DBMS. They are declarative, self-documenting and “obvious”. They cannot be bypassed (unless explicitly disabled or dropped). They are correct. They are fast. They support cascading referential actions (such as … Read more

designing database to hold different metadata information

This is called the Observation Pattern. Three objects, for the example Book Title=”Gone with the Wind” Author=”Margaret Mitchell” ISBN = ‘978-1416548898’ Cat Name=”Phoebe” Color=”Gray” TailLength = 9 ‘inch’ Beer Bottle Volume = 500 ‘ml’ Color=”Green” This is how tables may look like: Entity EntityID Name Description 1 ‘Book’ ‘To read’ 2 ‘Cat’ ‘Fury cat’ 3 … Read more

When and why are database joins expensive?

Denormalising to improve performance? It sounds convincing, but it doesn’t hold water. Chris Date, who in company with Dr Ted Codd was the original proponent of the relational data model, ran out of patience with misinformed arguments against normalisation and systematically demolished them using scientific method: he got large databases and tested these assertions. I … Read more

What is the best design for a database table that can be owned by two different resources, and therefore needs two different foreign keys? [closed]

Generally, there are two strategies to handle a situation like this: Use Exclusive FKs Essentially, each of the possible parent tables will have its own, separate foreign key in the child table, and there is a CHECK enforcing exactly one of them is non-NULL. Since FKs are only enforced on non-NULL fields (meaning, when a … Read more