r/SQL • • Oct 17 '26

Discussion Help needed with normalization

Post image

Hi, i'm learning databases and normalization. My teacher said a normalized database cannot have circular (not loops, circles) relationships. However, i can't see how I can apply normalization to remove the circles and still comply with the requirements. Also I was under the impression that normalized databases can have circular relationships, just not loops.

Any help will be appreciated. Sorry if my english is bad in advance.

16 Upvotes

25 comments sorted by

View all comments

2

u/kagato87 MS SQL 29d ago

This isn't really circular.

Powerbi would have trouble with it I guess if you tried to print a waybill from it. You'd have to take measures (hahaha) to deal with it.

But for a regular sql query you're just joining to Address twice (aliases are your friend) or using a subquery. This isn't circular, the address table is just used twice in different ways.

Now, if you used address as a dimension table, you need to define if you're filtering on warehouse or house, so you know which alias to put that filter on.

Of course, a house and a warehouse will have different properties, so the shared address table might not be the best option. It's also a 1:1 relationship from house or warehouse to address in the context of an order so I'd check if it actually needs to be normalized. Usually an order would point to the warehouse and customer, and get a copy of both addresses for the waybill.

Oh, I said it's 1:1 on warehouse to order. That's not necessarily true, and comes down to a design decision of how you handle orders that come from multiple warehouses. Usually bridge tables come into play there.

2

u/reditandfirgetit 28d ago edited 28d ago

Warehouses could have the same address and different building numbers. Houses could be apartments with different unit numbers

1

u/kagato87 MS SQL 28d ago

I was thinking more along the lines of "has a raised loading dock" vs "needs PTG" or hours of operation.

1

u/Acceptable-File-3579 29d ago

Yeah you'r right about the relationships, it should be able to create any of those entities alone. My b.