Complex and Legacy database schema

Source: Internet
Author: User

This paper mattered meters along

This address: http://blog.csdn.net/sushengmiyan/article/details/50414652


In this chapter, we focus on the most important part of your system:the Databaseschema, where your collection of Integrit Y rules resides-the model of the RealWorld that's you ' ve created.

If Your application can auction an item only once in the Real world, your database schema should guarantee. If a auction always have a starting price, the your database model should include an appropriate constraint.

If data satisfies all integrity rules, the data are consistent, a term you ' ll meet again 11.1.

We also assume that consistent data is correct:everything the database states, either explicitly or implicitly, is true; everything else is false.

If you want to know more about The theory behind this approach and look up the closed-world assumption (CWA).


In this chapter, we focus primarily on the most important parts of your system, the database schema, where your integrity rules reside --- the real-world models you create. If your application can only bid on one item in the real world, your database schema should guarantee that. If a bid always has a start price, your database model should include an appropriate constraint. If the data satisfies all integrity constraints, the data is consistent, and the term is met again in the 11.1 chapter.

We also assume that consistent data is correct, that all data expressed by the database, whether explicit or implicit, is correct, and that everything else is wrong. If you want to know more about the theory, refer to the Closed World hypothesis (CWA).


Major new features in JPA 2
? Schema generation and execution of custom SQL scripts during bootstrap are now standardized and can being configured on a pers Istence Unit.
? You can map and customize schema artifacts such as indexes and foreign key names with standard annotations.
? You can map foreign keys/many-to-one associations in composite primary the keys with @MapsId as "derived identity."

new features of JPA2

The SQL script that generated the schema and executed the custom at startup is now standardized and can be configured in the persistence unit.

You can map and customize schema objects, such as indexes and foreign keys, using standard annotation names.

You can map foreign keys, many-to-one relationships, and use @mapsid to define derived primary keys such as composite primary keys.

Sometimes you can start a project Top-down. There is no existing the database schema and maybe not even any Data-your application is completely new.

Many developers like-to-let Hibernate automatically generate the scripts for a database schema. You ' ll probably
Also let Hibernate deploy the schema on the test database on your development machine or your continuous build systems for Integration testing.

Later, a DBA would take the generated scripts and write an improved and final schema for production deployment.

The first part of this chapter shows what to improve the schema from within JPA and Hibernate, to make your DBA happy.
At the other end of the spectrum is systems with existing, possibly complex schemas, with years ' worth of data. Your New application is just a small gear in a big machine, and Your DBA won ' t allow any (sometimes even non-disruptive) c Hanges to the database.

You need a flexible object/relational mapping so you don ' t has to twist and bend the Java classes too much when things do N ' t fit right away.

This would be being the subject of the second half of this chapter, including a discussion of composite primary and foreign keys.

Sometimes, you can start a project from top to bottom. Your project projects are brand new, there are no existing databases.Shemanot even data. Many developers like to letHibernateto generate the databaseSchemathe script. You might letHibernatedeploy your test library on your development machine, or in your integration test. A little later,DBAwill get the generated script, improve it and write the final product release after the improvementSchema. The first part of this chapter shows you how to improveHibernateand theJPAgenerated byschema,to get yourDBAhappy.

At the other end of the spectrum is a system with multi-year data values that may be complex schemas.

Your new application is a small cog in a big machine. Your DBA will not allow you to make any database changes (even non-destructive). You need a flexible object / Relationship mapping so that you don't have to distort or flex your Java Implementation class for things that are out of date, which is the subject of the second part of this chapter, Includes a discussion of a composite primary key and a foreign key.

Excerpt from Hibernate and JPA Chapter Nineth. Reprint please indicate the source, thank you.

Complex and Legacy database schema

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.