> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getparable.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

# Planning Center Calendar SQL Queries

## Coordinate Your Ministry with Data-Driven Scheduling

Your church calendar is the heartbeat of ministry activity. With Parable's SQL access to Planning Center Calendar data, you can optimize facility usage, prevent conflicts, and ensure every event runs smoothly.

## Quick Start

Ready to explore your calendar data? Here's your first query to see upcoming events:

```sql theme={null}
-- See your next 10 upcoming events
SELECT 
    e.event_id,
    e.name,
    e.description,
    ei.starts_at,
    ei.ends_at,
    ei.location,
    ei.all_day_event
FROM planning_center.calendar_events e
JOIN planning_center.calendar_event_instances ei 
    ON e.event_id = ei.event_id
WHERE ei.starts_at >= CURRENT_TIMESTAMP
ORDER BY ei.starts_at
LIMIT 10;
```

## What You Can Do With Calendar Queries

### 📅 Event Management

* View all upcoming events and their details
* Track event approval status and workflows
* Monitor recurring events and patterns
* Identify scheduling gaps and opportunities

### 🏢 Resource Management

* Check room and equipment availability
* Track resource bookings and conflicts
* Analyze facility utilization rates
* Plan maintenance around usage patterns

### ⚠️ Conflict Detection

* Find double-booked resources
* Identify scheduling conflicts
* Prevent resource overbooking
* Manage approval workflows

### 📊 Usage Analytics

* Generate facility usage reports
* Track event attendance patterns
* Analyze resource utilization
* Optimize scheduling based on data

## Available Tables

Your Planning Center Calendar data is organized into these main tables:

| Table                              | What It Contains                 | Key Use Cases                                    |
| ---------------------------------- | -------------------------------- | ------------------------------------------------ |
| `calendar_events`                  | Event definitions and details    | Event information, approval status, descriptions |
| `calendar_event_instances`         | Specific occurrences of events   | Event times, locations, recurrence patterns      |
| `calendar_resources`               | Rooms, equipment, and facilities | Resource inventory, availability, specifications |
| `calendar_resource_bookings`       | Resource reservations            | Booking times, quantities, conflicts             |
| `calendar_conflicts`               | Scheduling conflicts             | Double bookings, resource conflicts              |
| `calendar_event_resource_requests` | Resource requests for events     | Pending requests, approval workflows             |
| `calendar_tags`                    | Event categorization tags        | Event types, ministries, categories              |

## Understanding Relationships

Calendar data uses relationship tables to maintain flexibility:

* `calendar_events_relationships` - Links events to owners, tags, and other entities
* `calendar_eventinstances_relationships` - Links instances to resources and bookings
* `calendar_resources_relationships` - Links resources to folders and approval groups
* `calendar_resourcebookings_relationships` - Links bookings to events and resources

## Next Steps

📚 **New to SQL?** Start with [Basic Queries](/planning-center/calendar/basic-queries) for simple, powerful queries you can use today.

🚀 **Ready for More?** Check out [Advanced Queries](/planning-center/calendar/advanced-queries) for conflict detection and resource optimization.

📊 **Need Reports?** See [Reporting Examples](/planning-center/calendar/reporting-examples) for complete facility and event reports.

🔍 **Want Details?** Review the [Data Model](/planning-center/calendar/data-model) for complete table documentation.

## Common Questions

### What's the difference between an event and an event instance?

* An **event** is the master definition (like "Sunday Service")
* An **event instance** is a specific occurrence (like "Sunday Service on Jan 7, 2024")
* One event can have many instances (especially for recurring events)

### How do I find available resources?

Check for resources without bookings during your timeframe:

```sql theme={null}
-- Find available rooms for a specific time
SELECT r.name, r.kind, r.quantity
FROM planning_center.calendar_resources r
WHERE r.kind = 'Room'
  AND NOT EXISTS (
    SELECT 1 FROM planning_center.calendar_resource_bookings rb
    WHERE rb.resource_id = r.resource_id
      AND rb.starts_at < '2024-01-15 14:00:00'  -- Your end time
      AND rb.ends_at > '2024-01-15 12:00:00'    -- Your start time
  );
```

### How are recurring events stored?

* The `calendar_events` table has the master event
* `calendar_event_instances` has each occurrence
* The `recurrence` field contains the recurrence pattern
* `recurrence_description` provides human-readable recurrence info

### What do approval statuses mean?

* `A` = Approved
* `P` = Pending
* `R` = Rejected
* `null` = No approval required

### How do I handle all-day events?

All-day events have `all_day_event = true` and use date boundaries:

```sql theme={null}
WHERE all_day_event = true
  AND DATE(starts_at) = '2024-01-15'
```

## Common Calendar Patterns

### Weekly Room Schedule

```sql theme={null}
-- See what's in each room this week
SELECT 
    r.name as room_name,
    e.name as event_name,
    ei.starts_at,
    ei.ends_at
FROM planning_center.calendar_resource_bookings rb
JOIN planning_center.calendar_resources r ON rb.resource_id = r.resource_id
JOIN planning_center.calendar_event_instances ei ON rb.event_instance_id = ei.event_instance_id
JOIN planning_center.calendar_events e ON ei.event_id = e.event_id
WHERE r.kind = 'Room'
  AND ei.starts_at >= DATE_TRUNC('week', CURRENT_DATE)
  AND ei.starts_at < DATE_TRUNC('week', CURRENT_DATE) + INTERVAL '1 week'
ORDER BY r.name, ei.starts_at;
```

### Today's Events

```sql theme={null}
-- All events happening today
SELECT 
    e.name,
    ei.starts_at::time as start_time,
    ei.ends_at::time as end_time,
    ei.location
FROM planning_center.calendar_events e
JOIN planning_center.calendar_event_instances ei ON e.event_id = ei.event_id
WHERE DATE(ei.starts_at) = CURRENT_DATE
   OR (ei.all_day_event = true AND DATE(ei.starts_at) <= CURRENT_DATE AND DATE(ei.ends_at) >= CURRENT_DATE)
ORDER BY ei.starts_at;
```

## Getting Help

* 🐛 Found an issue? Report it at [github.com/getparable/parable-api/issues](https://github.com/getparable/parable-api/issues)
* 📖 Need more examples? Check our other query guides in this folder
* 💬 Have questions? Reach out to your Parable support team

***

*Your ministry calendar tells a story of community and service. Let's help you manage it better.*
