database

1 view
Skip to first unread message

colaru

unread,
Jan 16, 2011, 4:53:22 PM1/16/11
to classic dev
Hi Richard

I started to create the database schema. I have some questions
regarding the relations between entities:

- I see in your entities that you are use id's and not other object
entities as references (I think you tray to catch just the relations
and not exactly how will be in real persistence); for JPA we will have
object references; for example in Brand class:

private Company company;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "company_id")
public Company getCompany() {
return this.company;
}

Now I created the database schema but we must discuss the relations
between objects. For example I see that you put in Chart:

private List<Item> items;

I expect to be a many to many here using a link table. It's at my
latitude how I will model this?

I cannot run the application now (before the last commit from you it
works) with - mvn gwt:run (and I have some compiling problems after
updating from repo). Do you can run it locally?

I made a push but I made a mistake in naming it. It contains my
generated entities and the database script. Are just to see how it
looks and is my first push. You can not accept it.

So, what I try to do now is to create the right relation between
entities - ant to create the database schema. I see that you uploaded
aa png file with a schema - is just as an example?

Regards,
Cristian

transmeta01

unread,
Jan 16, 2011, 5:31:57 PM1/16/11
to classic dev


On Jan 16, 4:53 pm, colaru <col...@gmail.com> wrote:
> Hi Richard
>
> I started to create the database schema. I have some questions
> regarding the relations between entities:
>
> - I see in your entities that you are use id's and not other object
> entities as references (I think you tray to catch just the relations
> and not exactly how will be in real persistence); for JPA we will have

What you see in the db design now is still work in progress. The
design is not complete. You are right, the first design iteration is
just to capture all the entities and their relationships. In did not
take into account how they were supposed to be implemented.

> object references; for example in Brand class:
>
>         private Company company;
>
>         @ManyToOne(fetch = FetchType.LAZY)
>         @JoinColumn(name = "company_id")
>         public Company getCompany() {
>                 return this.company;
>         }
>
> Now I created the database schema but we must discuss the relations
> between objects. For example I see that you put in Chart:
>
>         private List<Item> items;
>
> I expect to be a many to many here using a link table. It's at my
> latitude how I will model this?

Yes you have all the latitude to design the model as well. For Cart in
particular;
-a cart has 0 or more items.
-an item can be added to a cart more than once, example: a cart of
books can contains, 2 copies of the same book.

I suspect there will more of this type of relation in design of the
db. Let me know if you have suggestions or questions.

>
> I cannot run the application now (before the last commit from you it
> works) with - mvn gwt:run (and I have some compiling problems after
> updating from repo). Do you can run it locally?

Everything should run. Make sure to do a "mvn clean" first and
optionally a "mvn eclipse:clean eclipse:eclipse" if you are using
eclipse or a "mvn idea:idea" if you are using intellij's idea.

>
> I made a push but I made a mistake in naming it. It contains my
> generated entities and the database script. Are just to see how it
> looks and is my first push. You can not accept it.

Are you saying I should not pull the changes into my local repo? If
there are bit of code that you are not sure of, you can make another
clone of the repository and do your dev in it and merge when you are
satisfied.

>
> So, what I try to do now is to create the right relation between
> entities - ant to create the database schema. I see that you uploaded
> aa png file with a schema - is just as an example?

It's not an example, it's the first iteration of the design. Very
quickly done and very incomplete also. As mentioned above, you should
complete it.

>
> Regards,
> Cristian

colaru

unread,
Jan 17, 2011, 1:20:23 PM1/17/11
to classic dev
Hy Richard!

I have a question:

We will link a cart to a user or not? What is the relation between a
cart and a order? A cart will became a order if the user choose this.
In this case the order will be linked to the cart and just the order
will have a link to a user (because the cart is anonymous till it
became a order)?

Regards...

colaru

unread,
Jan 17, 2011, 1:31:56 PM1/17/11
to classic dev
Hi Richard!

The relation between order and cart is unclear. In your database
sample (the PNG file uploaded by you) I see a relation from order to a
cart (there are no products attached with a order - just to the cart)

Regards.

On Jan 17, 12:31 am, transmeta01 <transmet...@gmail.com> wrote:

transmeta01

unread,
Jan 17, 2011, 1:58:52 PM1/17/11
to classic dev
Hi Cristian, the way I see it, a cart is an incomplete order. A cart
can be saved to be checked out/paid for later. An order is a cart that
has been paid for by the customer and ready to ship. So an order is
just a cart that has been paid for.

Let me know if that is not clear enough. If not ask me more question.

Best regards

Cristian Olaru

unread,
Jan 17, 2011, 2:53:46 PM1/17/11
to class...@googlegroups.com
Hi Richard!

My database first proposition.

Regards,
Cristian
--
Cristian Olaru
weblog: http://olaru.blogspot.com
mobile: 0743163039
script.sql
classic_schema.JPG

colaru

unread,
Jan 17, 2011, 3:06:56 PM1/17/11
to classic dev
Hi Richard.

I also don't understand the meaning of Contact entity. It is
necessary?

Regards...
>  script.sql
> 10KViewDownload
>
>  classic_schema.JPG
> 165KViewDownload

Richard Mutezintare

unread,
Jan 17, 2011, 3:52:17 PM1/17/11
to class...@googlegroups.com
I don`t think contact entity is necessary. It does the same thing as Address. Address is a physical address (street name, ect...+ phone number)

Richard Mutezintare

unread,
Jan 17, 2011, 3:56:22 PM1/17/11
to class...@googlegroups.com
The design looks good. But I am sure it is complete. I am wondering whether user should have a company_id associated, since we have 3 type of users, it could be good to be able to gather information based on our users, per company. What do you think?

transmeta01

unread,
Jan 17, 2011, 3:58:53 PM1/17/11
to classic dev
Sorry I meant, I AM NOT SURE it is complete.

On Jan 17, 3:56 pm, Richard Mutezintare <transmet...@gmail.com> wrote:
> The design looks good. But I am sure it is complete. I am wondering whether
> user should have a company_id associated, since we have 3 type of users, it
> could be good to be able to gather information based on our users, per
> company. What do you think?
>
>
>
>
>
>
>
> On Mon, Jan 17, 2011 at 2:53 PM, Cristian Olaru <col...@gmail.com> wrote:
> > Hi Richard!
>
> > My database first proposition.
>
> > Regards,
> > Cristian
>

transmeta01

unread,
Jan 17, 2011, 6:14:52 PM1/17/11
to classic dev
Hi Cristian, good job. Some observations:
1- the table "order_2" should be "order",
2- the M:N join table "cart_has_items", the FK "idem_id" should be
"item_id"....
3- the promotion table is missing; if I remember correctly;
a promotion has a name,
a promotion has a description
a promotion belongs to a company (a promotion must belong to a
company)
a promotion has 1 or more items,
a beginDate,
an endDate,

the giftcard table is missing
-a giftcard has a name,
-a giftcard has a description,
-a giftcard is purchassed by a user (a giftcard must belong to a user)
-a giftard a dollar amount (it's value)
-a giftcard has a hascode (varchar(?))


I will let you know if I think of anything else.

Best regards
Richard


the wishlist table is missing
-a wishlist belong to a user,
-a wishlist has 1 or more items
-a giftcard has a expiry date
>  script.sql
> 10KViewDownload
>
>  classic_schema.JPG
> 165KViewDownload

Cristian Olaru

unread,
Jan 18, 2011, 2:27:02 AM1/18/11
to class...@googlegroups.com
Hi Richard,

I updated the scrips as you specified. For order table you see order_2 because a problem in designer, in scripts will me order.

Regards...
classic_schema_2.JPG

Cristian Olaru

unread,
Jan 18, 2011, 1:02:24 PM1/18/11
to class...@googlegroups.com
Hi Richard.

I want to ask if you will agree to replace your shared entities with the entities generated by my. I prefer in general to keep the entities clean (to be regenerated from database anytime). When the schema will became stable I will optimize it (make the entities to implement the same generic entity and so on).

Also all the relation between entities will be available via references and annotations. The performance will be achieved using lazy loading and caching (I will add caching to the entities).

Please let me know if you agree with this. Also we will be some problems (maybe circular dependencies) if you will reuse the entities for WS - will be hard for WS stack to marshal the objects to XML, JSON, etc.

But this is the way I choose to manage the entities.

Best regards,
Cristian

Richard Mutezintare

unread,
Jan 18, 2011, 8:00:43 PM1/18/11
to class...@googlegroups.com
Yes you can replace the entities in the shared folder with your generated entities. The current entities in the shared folder where prototypes. So it's okay to replace them. 

As the performance, I agree; lazy loading + caching is an excellent way of coding DAO. That been said, we must select the appropriate caching strategy; i.e what are we caching and when? What is the eviction policy?

We must avoid circular dependencies as much as possible. Circular dependencies are to be avoided! Have you found any? Please give examples?

Richard

Cristian Olaru

unread,
Feb 22, 2011, 8:44:14 AM2/22/11
to class...@googlegroups.com
Hi Richard.

See again the database. You say in every resource or just the resources that are dependent on company_id?

Regards...
classic_schema_2.JPG

Richard Mutezintare

unread,
Feb 22, 2011, 8:06:06 PM2/22/11
to class...@googlegroups.com
Hi Cristian, can you put me in the context of your question. I am not sure I understand what you mean?

transmeta01

unread,
Feb 24, 2011, 5:46:23 PM2/24/11
to classic dev
There should another table: "Inventory" to hold inventory data, this
table would, obviously contain a company_id FK. And maybe an
"Order_detail" table...Still thinking about it.

On Feb 22, 8:06 pm, Richard Mutezintare <transmet...@gmail.com> wrote:
> Hi Cristian, can you put me in the context of your question. I am not sure I
> understand what you mean?
>
>
>
>
>
>
>
> On Tue, Feb 22, 2011 at 8:44 AM, Cristian Olaru <col...@gmail.com> wrote:
> > Hi Richard.
>
> > See again the database. You say in every resource or just the resources
> > that are dependent on company_id?
>
> > Regards...
>
> > ---------- Forwarded message ----------
> > From: Cristian Olaru <col...@gmail.com>
> > Date: Tue, Jan 18, 2011 at 9:27 AM
> > Subject: Re: database
> > To: class...@googlegroups.com
>
> > Hi Richard,
>
> > I updated the scrips as you specified. For order table you see order_2
> > because a problem in designer, in scripts will me order.
>
> > Regards...
>
Reply all
Reply to author
Forward
0 new messages