text:
Q: SQL Server two-way cascade? I'm trying to put together a database in SQL Server Management Studio 2008 which will manage the data without having to programatically process the data but I'm having some issues at the moment.
I have a main table called person, this table holds core data about a person and this is linked to a second table called customer in which they are included if they wish to have transaction permissions. Once a transaction has taken place the customer ID is placed into the transaction table.
|Person|   |Customer|   |Transaction|
|------|   |--------|   |-----------|
|  ID  |-\ |   ID   |-\ |    ID     |
|      |  \| person |  \|  Customer |
|      |   |        |   |           |

Of the two links, the ID's are PK's and the secondary items (person/customer) are FK's.
The problem I am having with this arrangement lies in the requirement that a person has to be kept if they have made a transaction and thus their customer ID appears in the transaction table.
I am not 100% sure on what approach to take, would a 'Delete Rule - Cascade' between person-customer with a 'Delete Rule - No Action' between Customer - Transaction create the desired effect?
Any thoughts approach or a better approach would be very much appreciated on this issue.

A: I think, yes, an
ON DELETE CASCADE

clause in Customer.Person foreign key, and an
ON DELETE NO ACTION

clause in Transaction.Customer foreign key would have the desired effect.
Then any attemp to delete a Person, will delete the related Customer row, unless there are related Transcations. That will raise an error and the DELETE would be rolled back.

A: You could just have a delete trigger on the person table that stops the delete if the to-be-deleted person has any records in the Transaction table.


text:
Q: How to print an array list (that's using char) in a JTextArea? Okay, so I have to make a game for school that's called "Angry Tanks" it's basically a simpler version of Angry Birds.
We have to read in a textfile to use as a landscape for our game, this text file contais spaces and hashtags, the hastags represent the land.
The file has bean read and inserted into an arraylist, there is a public method calles getLandscapeFromFile().
I am trying to print the landscape into a JTextArea called textArea, using a loop that replaces all the hashtags with an image. Am I supposed to use a textArea or should another panel be used?
This is the code I've tried but doesn't work:
for (int i = 0; i < Landscape.getLandscapeFromFile().size(); i++) {
            for (char[] c : Landscape.getLandscapeFromFile()) {
                textArea.append(String.valueOf(c[i]));
}
}

I've been trying all sort of stuff, but nothing seems to work...
And by the way, I'm not very good at Java, this is only my first year studying IT.

A: The problem is in your second loop
You select i char of word
for (char[] c : Landscape.getLandscapeFromFile()) {
        textArea.append(String.valueOf(c[i]));
    }

You probably wonted to write each character of that array.
for (char[] c : Landscape.getLandscapeFromFile()) {
    textArea.append(String.valueOf(c));
}

As you task is to write the content form File to textArea you should do this.
TIP: You should avoid to access the loading method twice as it can time consuming user a local variable.
List<char[]> landscapes = Landscape.getLandscapeFromFile(); //Read once

for(char[] landscape : landscapes) {//Iterate through all landscapes
    stextArea.append(new String(landscape)); //Create new String for char array
}

A: You can use a StringBuilder:
StringBuilder sb = new StringBuilder();

for (int i = 0; i < Landscape.getLandscapeFromFile().size(); i++) {
    for (char[] c : Landscape.getLandscapeFromFile()) {
        sb.append(String.valueOf(c));
    }
}

textArea.setText(sb.toString());

redpajama_set_name: RedPajamaStackExchange