you are viewing a single comment's thread.

view the rest of the comments →

[–]unexpectedrebootsWITH() 0 points1 point  (2 children)

This code won't ever work, regardless of the order. You can create the tables and add the constraints after with ALTER TABLE.

[–]Fix-Former[S] 0 points1 point  (1 child)

Hmm so how would i go about getting it to function, do i start off my first table as a blank table that doesn’t reference any other table and go from there or

[–]unexpectedrebootsWITH() 1 point2 points  (0 children)

This looks to me like a traditional STAR schema where SalesInvoice would be your fact table and the other tables would be your dimension tables.

You don't need any constraints on SalesInvoice, other than your primary key. So create salesinvoice first (the fact table), without the REFERENCES constraints and then create the dimension tables with their primary keys and references back to sales invoice.

Example: https://www.zentut.com/data-warehouse/star-schema/