The relationship between the anionic groups of beta-barium borate and lithium borate nonlinear optical (NLO) crystals and their bonding, electronic structure, and transmission cutoffs has been studied using the discrete variational self-consistent multipolar X-alpha method [B. Delley and D. E. Ellis, J. Chem. Phys. 76, 1949 (1982)] for the electronic structure of the borate anionic groups, coupled with experimental studies of the band gap, absorption edge, and valence bands, using vacuum ultraviolet spectroscopy and valence-band x-ray photoemission spectroscopy. The band gap of beta-BaB2O4 (BBO) is 6.43 eV while LiB3O5(LBO) has a larger band gap of 7.78 eV. The structures of LBO and BBO differ principally in two aspects: the bonding in the borate anionic groups, and the isolation or linkage of the anionic groups in the crystal. BBO consists of (B3O6)3- anionic groups, with boron trigonally coordinated by oxygen; these groups are isolated in the crystal structure. LBO, however, is based on (B3O7)5- anionic groups, with boron either trigonally or tetrahedrally coordinated by oxygen, these groups are linked throughout the crystal. These structural differences between BBO and LBO lead to a larger band-gap energy in LBO. The linkage of LBO's anionic groups removes states from the top of the valence band which arise from the nonbonding terminal oxygen atoms present in BBO's unlinked anionic groups and also partially removes the pi-conjugated orbitals associated with trigonally coordinated boron-oxygen bonding. The relationship between the crystal structure and the electronic structure can be seen as an extension of the molecular-engineering approach to search for additional NLO crystals in the uv range.