add Makefile for sqlite
[platform/upstream/crda.git] / 01-regulatory.sql
1 use regulatory;
2
3 /* This is the DB schema of the CRDA database */
4
5 /* Each regulatory rule defined has a set of frequency ranges with
6  * an attached power rule. */
7 drop table if exists reg_rule;
8 CREATE TABLE reg_rule (
9         reg_rule_id     INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
10         freq_range_id   INTEGER NOT NULL default '0',
11         power_rule_id   INTEGER NOT NULL default '0'
12 );
13
14 /* Frequency ranges */
15 drop table if exists freq_range;
16 CREATE TABLE freq_range (
17         freq_range_id           INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
18         start_freq_khz          INTEGER NOT NULL default '0',
19         end_freq_khz            INTEGER NOT NULL default '0',
20         max_bandwidth_khz       INTEGER NOT NULL default '0',
21         modulation_cap          INTEGER NOT NULL default '0',
22         misc_restrictions       INTEGER NOT NULL default '0'
23 );
24
25 /* Power rule. Each power rule can be attached to a frequency range.
26  * We use mili to avoid floating point in the kernel.
27  * EIRP and IR  is given in mili Bells with respect to 1 mili Watt, so mbm
28  * Antenna gain is given in mili Bells with respect to the isotropic, so mbi.
29  *
30  * Note: a dipole antenna has a gain of 2.14 dBi, so 2140 mBi)
31  */
32 drop table if exists power_rule;
33 CREATE TABLE power_rule (
34         power_rule_id           INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
35         environment_cap         char(1) NOT NULL,
36         max_antenna_gain_mbi    INTEGER NOT NULL default '0',
37         max_ir_ptmp_mbm         INTEGER NOT NULL default '0',
38         max_ir_ptp_mbm          INTEGER NOT NULL default '0',
39         max_eirp_pmtp_mbm       INTEGER NOT NULL default '0',
40         max_eirp_ptp_mbm        INTEGER NOT NULL default '0'
41 );
42
43 /* Each collection has a list of rules attached it. The reg_collection_id is what we use
44  * to group together a bunch of rules into a group. */
45 drop table if exists reg_rules_collection;
46 CREATE TABLE reg_rules_collection (
47         entry_id                INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
48         reg_collection_id       INTEGER NOT NULL default '0',
49         reg_rule_id             INTEGER NOT NULL default '0'
50 );
51
52 /* ISO3166-alpha2 <--> regulatory collection id mapping. Each country can have
53  * more than one collection id. This allows for large flexibility on how
54  * we can group together in collections rule ids. Right now we group together
55  * common rules into bands groups (2 GHz and 5 GHz for now) */
56 drop table if exists reg_country;
57 CREATE TABLE reg_country (
58         reg_country_id          INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
59         alpha2                  char(2) NOT NULL,
60         reg_collection_id       INTEGER NOT NULL default '0'
61 );