# Running a "script" to add relations

**URL:** <https://forum.servoy.com/t/running-a-script-to-add-relations/6426>\
**Category:** Classic Servoy\
**Created:** [September 8, 2006, 1:03pm UTC](https://forum.servoy.com/t/running-a-script-to-add-relations/6426 "2006-09-08T13:03:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![birgit](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@birgit](https://forum.servoy.com/u/birgit)\
**Post date:** [September 8, 2006, 1:03pm UTC](https://forum.servoy.com/t/running-a-script-to-add-relations/6426/1 "2006-09-08T13:03:03Z")

</div>

I have a table persons and a table profile. Each person must have a profile, a profile may be used by 1 or many persons (1:n).

I my data modelling tool I define a constraint called “persons\_must\_have” between the primary key in persons and a foreign key in profiles.

Servoy creates a relation called persons\_must\_have\_FK on table profile.

I’d like to have two relations:

1. persons\_must\_have on table persons
2. profiles\_may\_be\_used on table profiles.

Servoy could create the first relation (unfortunately it does it vice versa). But it does not have enough information for the second relation. The relation name is missing. But I can get this information from my modelling tool. I could create a script like

````auto
create relation x from persons to profiles using (pk1=fk1, pk2=fk2,...)
``` and

````

create relation y from profiles to persons using (pk3=fk3, pk4=fk4,…)

```auto

It would be nice if I could run the script somewhere in servoy (against the repository?) to create relations automatically (without dialog).

Since I have around 70 constraints, I'll have to create around 140 relations by hand otherwise.

Any other ideas are very welcome. Best regards
Birgit
```
