13 Aralık 2018

https://netbeans.org/kb/docs/ide/java-db.html

https://netbeans.org/kb/docs/ide/java-db.html

Working with the Java DB (Derby) Database

This document demonstrates how to set up a connection to Java DB database in NetBeans IDE. Once a connection is made, you can begin working with the database in the IDE, allowing you to create tables, populate them with data, run SQL statements and queries, and more.
The Java DB database is Sun's supported distribution of Apache Derby. Java DB is a fully transactional, secure, standards-based database server, written entirely in Java, and fully supports SQL, JDBC API, and Java EE technology. The Java DB database is packaged with the GlassFishapplication server, and is included in JDK 6 as well. For more information on Java DB database, consult the official documentation.
Contents
Content on this page applies to NetBeans IDE 7.2, 7.3, 7.4 and 8.0
To follow this tutorial, you need the following software and resources.
Software or ResourceVersion Required
NetBeans IDE7.2, 7.3, 7.4, 8.0, Java EE
Java Development Kit (JDK)Version 7 or 8
Java DBversion 10.4.x, 10.5.x
Note.
  • Java DB is installed when you install JDK 7 or JDK 8 (except on Mac OS X). If you are using Mac OS X you can download and installJava DB manually or use the Java DB that is installed by Java EE version of the NetBeans IDE installer.

Configuring the Database

If you have the GlassFish Server registered in your NetBeans IDE installation, Java DB will already be registered for you. Therefore, you can skip ahead to Starting the Server and Creating a Database.
If you downloaded the GlassFish server separately and need help registering it in NetBeans IDE, see Registering a GlassFish Server Instancein the IDE's Help Contents (F1).
If you just downloaded Java DB on its own, perform the following steps.
  1. Run the self-extracting file. A folder named 'javadb' will be created in the same location as the file. If you just downloaded Java DB and want to have the database server reside in a different location than where it was extracted to, you should relocate it now.
  2. On your system, create a new directory to be used as a home directory for the individual instances of the database server. For example, you can create this folder in the Java DB root directory (javadb) or in any other location.
Before continuing further, it is important to understand the components found in Java DB's root directory:
  • The demo subdirectory contains the demonstration programs.
  • The bin subdirectory contains the scripts for executing utilities and setting up the environment.
  • The javadoc subdirectory contains the API documentation that was generated from source code comments.
  • The docs subdirectory contains the Java DB documentation.
  • The lib subdirectory contains the Java DB jar files.

Registering the Database in NetBeans IDE

Now that the database is configured, perform the following steps to register Java DB in the IDE.
  1. In the Services window, right-click the Java DB Database node and choose Properties to open the Java DB Settings dialog box.
  2. For the Java DB Installation text field, enter the path to the Java DB root directory (javadb) that you specified in the previous step.
  3. For Database Location, use the default location if a location is already provided. Click OK
    For example, the default location might look like C:\Documents and Settings\username\.netbeans-derby on a Windows machine.
    Java DB settings dialog
    Note. If the Database Location field is empty you will need to set the path to the directory that contains your databases. You will need to create a directory for the databases if no directory exists.

Starting the Server and Creating a Database

The Java DB Database menu options are displayed when you right-click the Java DB node in the Services window. This contextual menu items allow you to start and stop the database server, create a new database instance, as well as register database servers in the IDE (as demonstrated in the previous step). To start the database server:
  1. In the Services window, right-click the Java DB node and choose Start Server. Note the following output in the Output window, indicating that the server has started:
    Output window display after starting the database server
  2. Right-click the Java DB node and choose Create Database to open the Create Java DB Database dialog.
  3. Type contact for the Database Name.
  4. Type nbuser for the User Name and Password. Click OK.
    Create Java DB Database dialog
    Note. The Database Location is the default location set during installation of Java DB from GlassFish. If you installed Java DB separately, this location might be different.

After you create the database, if you expand the Databases node in the Services window you can see that the IDE created a database connection and that the database was added to the list under the Java DB node.

03 Aralık 2018

https://www.cs.sfu.ca/CourseCentral/354/zaiane/material/postscript/Chapter2.pdf

 Attributes
It is possible to de ne a set of entities and the relationships among them in a number of di erent ways. The main difference is in how we deal with attributes.
Consider the entity set employee with attributes employee-name and phone-number.
We could argue that the phone be treated as an entity itself, with attributes phone-number and location.
Then we have two entity sets, and the relationship set EmpPhn de ning the association between employees and their phones.
This new de nition allows employees to have several (or zero) phones.
New de nition may more accurately re ect the real world.

Mapping Cardinalities: express the number of entities to which another entity can be associated via a relationship. For binary relationship sets between entity sets A and B, the mapping cardinality must be one of:
1. One-to-one: An entity in A is associated with at most one entity in B, and an entity in B is associated with at most one entity in A. (Figure 2.3)
2. One-to-many: An entity in A is associated with any number in B. An entity in B is associated with at most one entity in A. (Figure 2.4)
3. Many-to-one: An entity in A is associated with at most one entity in B. An entity in B is associated with any number in A. (Figure 2.5)
4. Many-to-many: Entities in A and B are associated with any number from each other.

Existence Dependencies:
if the existence of entity X depends on the existence of entity Y, then X is said to be existence dependent on Y.
(Or we say that Y is the dominant entity and X is the subordinate entity.)
For example,
{ Consider account and transaction entity sets, and a relationship log between them.
{ This is one-to-many from account to transaction.
{ If an account entity is deleted, its associated transaction entities must also be deleted.
{ Thus account is dominant and transaction is subordinate.