We are a group of 4 software development students currently studying at the Cape Peninsula University of Technology. Currently, we are tasked with developing a web application that functions as a online store. We decided to do the back-end in Java while making use of Google Guice for persistence(which is mostly irrelevant for my question). The general idea so far to use PHP to create the website.
We decided that we would like to try, after handing in the project, and register a business to actually implement the website.
The problem we have been experiencing is with the domain model. These are mostly small issues, however they are starting to impact the schedule of our project. Since we are all young IT students, we have virtually no experience in the business world. As such, we spend quite a significant amount of time planning the domain model in the first place. Now, some of the issues we’re picking up is say the reference between the Customer entity and the order entity. Currently, we don’t have the customer id in the order entity and we have a list of order entities in the customer entity.
Lately, I have wondered if the persistence mechanism will put the client id physically in the order table, even if it’s not in the entity? So, I started wondering, if you load a customer object, it will search the entire order table for orders with the customer’s id. Now, say you have 10 000 customers and 500 000 orders, won’t this take an extremely long time? There are also some business processes that I’m not completely clear on.
Finally, my question is: does anyone know of a sample domain model out there that is similar to what we’re trying to achieve that will be safe to look at as a reference? I don’t want to be accused of stealing anybody’s intellectual property, especially since we might implement this as a business.
I suggest you spend some time knowing about data modeling. I see that it is an essential skill to get acquainted with even if you don’t use RDBMS.
we don’t have the customer id in the order entity and we have a list of order entities in the customer entity.
This is clearly a design mistake. The business rule is:
Each Customer has 0,1,more Orders
And
Each Order is made by 1 Customer
This is a One-to-Many relationship that implies placing the Primary Key of Customer in the Order table acting as a Foreign Key, both these columns are physical columns in the database.
Lately, i have wondered if the persistence mechanism will put the client id physically in the order table, even if it’s not in the entity.
No, the table design is static at run time. Your web application does not alter the database tables design during execution. Your web application only changes data and associations between tables (the values in the Foregoing Keys) if needed as well as delete rows, add rows and so on. The columns don’t change.
if you load a customer object, it will search the entire order table for orders with the customer’s id. Now, say you have 10,000 customers and 500,000 orders, won’t this take an extremely long time?
It does not take time to locate an order given a customer id. This is because in your database design, you’d normally create an Index (a database structure sometimes used for searching the database fast) on the foreign key value. Good database design implies that you specify columns that you choose to build the index on to max. performance of the system.
does anyone know of a sample domain model out there that is similar to what we’re trying to achieve that will be safe to look at as a reference?
As for an example, there must be some but I can’t provide any except Adventure Works (find the colored picture in the page), which is not exactly what you want but has many tables in common with your objective, specially on the Sales subject area (Order, Credit Card, etc.).
Also note that there are components you could buy to handle some of this stuff but I am not a PHP guy and I can’t recommend any now.