What is MansionSQL?
MansionSQL is an SQL language written for the birth chart. Once the chart is calculated, it opens as six main tables. planets holds the ten planets, chart every body and point the chart calculated, houses the twelve houses, aspects every aspect found, stars the fixed stars and lots the 38 Arabic lots. A query picks what it wants with SELECT, filters it with WHERE and counts it with GROUP BY.
A query runs in milliseconds on AstroMansion's own engine. Only SELECT is accepted, and every other command is refused before it reaches the engine, so a query cannot change any data. An answer holds at most 100 rows. A longer answer is never cut short, it is refused openly.
The language's keywords and column names are English, and so are the sign and planet names in an answer. The tables in this guide are written as the MansionSQL page shows them.
The example birth
Every example was calculated with the documentation's shared birth. The same birth is open to everyone in the MansionSQL page's trial, so you can run each query here yourself and see the same answer.
- Birth
- London, 15 July 1990, 14:30
- House system
- Placidus
- Bodies and points in the chart
- 55
- Planets
- 10
The main placements
Where are the Sun, the Moon and the Ascendant?
SELECT name, sign, dms, house
FROM chart
WHERE name IN ('Sun', 'Moon',
'Ascendant')
| name | sign | dms | house |
|---|---|---|---|
| Sun | Cancer | 22°48′21″ | 9 |
| Moon | Aries | 24°8′6″ | 6 |
| Ascendant | Scorpio | 1°58′5″ | 1 |
The Sun is in Cancer in the 9th house, the Moon in Aries in the 6th, and the Ascendant at 1°58′ Scorpio. The Ascendant is not a planet but the eastern point of the horizon, so the query reads the chart table, which holds every body and point of the chart, rather than planets. The dms column writes the place within the sign in degrees, minutes and seconds.
Which planets are retrograde?
SELECT name, sign, dms
FROM planets
WHERE retrograde = 1
| name | sign | dms |
|---|---|---|
| Saturn | Capricorn | 21°57′32″ |
| Uranus | Capricorn | 6°57′51″ |
| Neptune | Capricorn | 12°55′10″ |
| Pluto | Scorpio | 14°59′57″ |
In this birth Saturn, Uranus, Neptune and Pluto move backwards as seen from Earth. The outer planets stay retrograde for months every year, so charts with all four retrograde at once are common. The condition retrograde = 1 keeps only the planets that move backwards.
The tightest aspects
Which are the five tightest aspects between planets?
SELECT a, b, aspect, orb
FROM aspects
WHERE a IN (SELECT name FROM planets)
AND b IN (SELECT name FROM planets)
ORDER BY orb
LIMIT 5
| a | b | aspect | orb |
|---|---|---|---|
| Sun | Jupiter | Conjunction | 0.243 |
| Moon | Venus | Sextile | 0.351 |
| Jupiter | Saturn | Opposition | 0.604 |
| Sun | Saturn | Opposition | 0.847 |
| Sun | Moon | Square | 1.329 |
The aspects table holds both sides of each aspect (a and b), its name and its orb. The orb is how many degrees the aspect is away from exact. The smaller the orb, the tighter the aspect, and in a traditional reading the stronger it acts. The tightest aspect in this birth is the conjunction of the Sun and Jupiter, with an orb of 0.243 degrees, about 15 minutes of arc.
The two subqueries require both sides of the aspect to be planets. The table holds 199 aspects in this birth, and without the subqueries the lunar nodes, Lilith and the hypothetical planets come into the list too. A subquery must select a single column, and one that selects two is refused.
Elements and signs
How are the planets spread across the elements?
SELECT ELEMENT(sign) AS element,
COUNT(*) AS planet_count
FROM planets
GROUP BY ELEMENT(sign)
ORDER BY planet_count DESC
| element | planet_count |
|---|---|
| earth | 4 |
| water | 3 |
| fire | 2 |
| air | 1 |
ELEMENT gives a sign's element, and GROUP BY gathers the planets by it. Four planets are in earth signs (Mars in Taurus, and Saturn, Uranus and Neptune in Capricorn). Three are in water (the Sun and Jupiter in Cancer, Pluto in Scorpio), two in fire (the Moon in Aries, Mercury in Leo) and one in air (Venus in Gemini). Write the same query with MODALITY and you get the spread across cardinal, fixed and mutable signs.
Which signs hold more than one planet?
SELECT sign, COUNT(*) AS planet_count
FROM planets
GROUP BY sign
HAVING COUNT(*) >= 2
ORDER BY planet_count DESC
| sign | planet_count |
|---|---|
| Capricorn | 3 |
| Cancer | 2 |
HAVING filters after the groups are formed. Here it keeps the signs that hold at least two planets. The three planets in Capricorn are Saturn, Uranus and Neptune, a generational signature found in the chart of everyone born in 1989 and 1990. Many astrologers call three or more planets in one sign a stellium. To change the threshold, write HAVING COUNT(*) >= 3.
A planet's strength in its sign
Which planets are in a strong or weak sign?
SELECT name, sign,
DIGNITY(name, sign) AS dignity
FROM planets
WHERE DIGNITY(name, sign)
<> 'peregrine'
| name | sign | dignity |
|---|---|---|
| Mars | Taurus | detriment |
| Jupiter | Cancer | exaltation |
| Saturn | Capricorn | domicile |
In traditional astrology the sign a planet stands in gives it strength or weakness. This is called essential dignity. A planet in a sign it rules is in its domicile, and in the sign of its exaltation it is in exaltation. Opposite a sign it rules it is in detriment, and opposite its exaltation it is in fall.
In this birth Saturn is in Capricorn, a sign it rules, and Jupiter in Cancer, the sign of its exaltation. Mars is in Taurus, opposite Scorpio, which it rules, and so in detriment. The other planets are in none of these four states, and the engine writes them as peregrine.
DIGNITY reads the table of the seven classical planets. Uranus, Neptune and Pluto rule no sign in the tradition, so they always return peregrine. The minor dignities of triplicity, term and face are not reported, because they need a degree and the difference between day and night, which a sign alone does not give. In the tradition, peregrine means a planet with no dignity at all. Here it says that none of the four states applies.
Angles, houses and their rulers
Which signs are on the four angles?
SELECT number, sign, dms
FROM houses
WHERE number IN (1, 4, 7, 10)
| number | sign | dms |
|---|---|---|
| 1 | Scorpio | 1°58′5″ |
| 4 | Aquarius | 13°2′56″ |
| 7 | Taurus | 1°58′5″ |
| 10 | Leo | 13°2′56″ |
In quadrant house systems such as Placidus, the cusps of the 1st, 4th, 7th and 10th houses are the chart's four angles. They are the Ascendant, the Imum Coeli (IC), the Descendant and the Midheaven (MC). Opposite angles fall in opposite signs at the same degree. With the Ascendant at 1°58′ Scorpio the Descendant is at 1°58′ Taurus, and with the MC at 13°2′ Leo the IC is at 13°2′ Aquarius. ANGULAR(house) says whether a house is angular, succedent or cadent.
Which house is each planet in, and who rules it?
SELECT p.name, p.house,
h.sign AS cusp_sign,
RULER(h.sign) AS cusp_ruler
FROM planets p
JOIN houses h ON p.house = h.number
| name | house | cusp_sign | cusp_ruler |
|---|---|---|---|
| Sun | 9 | Cancer | Moon |
| Moon | 6 | Aries | Mars |
| Mercury | 9 | Cancer | Moon |
| Venus | 8 | Taurus | Venus |
| Mars | 7 | Taurus | Venus |
| Jupiter | 9 | Cancer | Moon |
| Saturn | 3 | Capricorn | Saturn |
| Uranus | 3 | Capricorn | Saturn |
| Neptune | 3 | Capricorn | Saturn |
| Pluto | 1 | Scorpio | Mars |
JOIN joins two tables over a shared value. Here each planet meets the row of the house it stands in. A house's cusp sign need not be the planet's own sign. Mercury is in Leo, but the 9th house begins in Cancer, so the ruler of Mercury's house is the Moon. Venus is in the 8th house, which begins in Taurus, so Venus stands in a house it rules itself.
RULER gives the traditional ruler only. Mars rules Scorpio, Saturn Aquarius and Jupiter Pisces. Pluto is in the 1st house, which begins in Scorpio, so the answer gives the traditional ruler Mars rather than the modern ruler Pluto.
Which houses are empty?
SELECT number, sign
FROM houses h
WHERE NOT EXISTS (
SELECT 1 FROM planets p WHERE p.house = h.number
)
| number | sign |
|---|---|
| 2 | Scorpio |
| 4 | Aquarius |
| 5 | Pisces |
| 10 | Leo |
| 11 | Virgo |
| 12 | Libra |
NOT EXISTS is true when the subquery inside it finds no row. Here the subquery looks in each house for a planet standing there. When it finds none, the house counts as empty. Six houses hold no planet in this birth. A house without a planet is not an unimportant house. It is read through the ruler of its cusp sign, which is exactly what the RULER query above shows.
Looking for empty houses with the bodies column of the houses table gives another answer. That column counts not only the planets but all 55 bodies and points of the chart. Among them are the lunar nodes, Lilith, the hypothetical planets, some minor bodies and calculated points.
SELECT number, sign
FROM houses
WHERE bodies = 0
| number | sign |
|---|---|
| 4 | Aquarius |
This query finds only the 4th house, because the other five houses hold no planet but do hold another body or point. Astrology usually counts a house as empty or occupied by its planets, which is why the page's question looks at the planets.
The Lots of Fortune and Spirit
Where are the Lots of Fortune and Spirit?
SELECT name, sign, dms, house
FROM lots
WHERE name IN ('Fortune', 'Spirit')
| name | sign | dms | house |
|---|---|---|---|
| Fortune | Leo | 3°17′51″ | 9 |
| Spirit | Aquarius | 0°38′20″ | 3 |
Most Arabic lots are found by moving on from the Ascendant by the arc between two bodies. In a day birth the Lot of Fortune is Ascendant + Moon − Sun, and the Lot of Spirit Ascendant + Sun − Moon. In a night birth the two formulas swap. The engine counts a birth as a night birth when the Sun is below the horizon.
The example birth is in the afternoon, with the Sun in the 9th house above the horizon, so it is a day chart. Add the arc from the Sun to the Moon to the Ascendant at 1°58′ Scorpio, and the Lot of Fortune falls at 3°17′ Leo. The lots table holds all 38 lots the engine calculates.
Astrological functions
These functions can be used anywhere in a query, in SELECT, WHERE, GROUP BY and ORDER BY. Each reads a table or does simple arithmetic, and none calculates the chart again.
ELEMENT(sign)gives the sign's element. The answers arefire,earth,airandwater.MODALITY(sign)says whether it is cardinal, fixed or mutable.RULER(sign)gives the traditional ruler.DIGNITY(body, sign)reads the essential dignity of the seven classical planets.DECAN(longitude)says which ten-degree part of the sign a degree falls in, the first, second or third decan.ANGULAR(house)says whether a house is angular, succedent or cadent.ORB(a, b)gives the angle between two longitudes, never more than 180 degrees.
Aggregates such as COUNT, AVG, MIN, MAX and SUM work too, and so do CASE WHEN, LIKE, BETWEEN and EXISTS. The full list of the language is in the documentation.
On your own chart and in the API
The MansionSQL page has ten ready questions and a trial box. The trial on the example birth is free for everyone. To run a query on your own birth, tick My own birth and enter your birth details. This needs the Basic, Pro or Enterprise plan.
The same queries run in the API through POST /v1/query. There you can bring a second birth into a synastry query through the natal_b table, and set the sky of a moment beside the birth chart through the transits table. The answer comes as JSON, and you can also take it as CSV or as a table to read in a terminal. Developers find the details on the developers page.
Sources and calculation
Every table was calculated with the documentation's shared birth on AstroMansion's engine and written as the MansionSQL page shows it. The essential dignities and the formulas of the Arabic lots follow their definitions in the traditional sources.