~misterio/BSI-SCC0540-listas

4d986796f67a03f848ee87e52200f9351e372b04 — Gabriel Fontes 6 months ago 6c1b7c2
algumas letras da lista 6
A lista6/.envrc => lista6/.envrc +1 -0
@@ 0,0 1,1 @@
use flake

A lista6/.gitignore => lista6/.gitignore +1 -0
@@ 0,0 1,1 @@
schema.sql

A lista6/ex-a.sql => lista6/ex-a.sql +5 -0
@@ 0,0 1,5 @@
SELECT DISTINCT f_nome, cor
    FROM fornecedores
    NATURAL JOIN catalogo
    NATURAL JOIN pecas
    WHERE cor = 'vermelho';

A lista6/ex-b.sql => lista6/ex-b.sql +5 -0
@@ 0,0 1,5 @@
SELECT DISTINCT f_nome
    FROM fornecedores
    NATURAL JOIN catalogo
    NATURAL JOIN pecas
    WHERE cor = 'vermelho' OR endereço = 'Sao Carlos';

A lista6/ex-i.sql => lista6/ex-i.sql +6 -0
@@ 0,0 1,6 @@
SELECT p_id, COUNT(f_id)
    FROM pecas
    NATURAL JOIN catalogo
    NATURAL JOIN fornecedores
    GROUP BY p_id
    HAVING COUNT(f_id) >= 2;

A lista6/ex-j.sql => lista6/ex-j.sql +5 -0
@@ 0,0 1,5 @@
SELECT COUNT(p_id)
    FROM catalogo
    NATURAL JOIN fornecedores
    WHERE f_nome = 'João';


A lista6/ex-k.sql => lista6/ex-k.sql +6 -0
@@ 0,0 1,6 @@
-- K
SELECT p_nome, MAX(preco), MIN(preco), AVG(preco)
    FROM catalogo
    NATURAL JOIN pecas
    WHERE cor = 'verde'
    GROUP BY p_nome;

A lista6/ex-l.sql => lista6/ex-l.sql +6 -0
@@ 0,0 1,6 @@
-- L
SELECT f_nome, COUNT(*)
    FROM fornecedores
    NATURAL JOIN catalogo
    NATURAL JOIN pecas
    GROUP BY f_nome;

A lista6/flake.lock => lista6/flake.lock +43 -0
@@ 0,0 1,43 @@
{
  "nodes": {
    "nixpkgs": {
      "locked": {
        "lastModified": 1634782485,
        "narHash": "sha256-psfh4OQSokGXG0lpq3zKFbhOo3QfoeudRcaUnwMRkQo=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "34ad3ffe08adfca17fcb4e4a47bb5f3b113687be",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs",
        "utils": "utils"
      }
    },
    "utils": {
      "locked": {
        "lastModified": 1634851050,
        "narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "c91f3de5adaf1de973b797ef7485e441a65b8935",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    }
  },
  "root": "root",
  "version": 7
}

A lista6/flake.nix => lista6/flake.nix +38 -0
@@ 0,0 1,38 @@
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, utils }:
    utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs { inherit system; };
        pname = "lista5";
        group = [ "10856803" "11914601" "11816021" ];
      in
      rec {
        packages.${pname} =
          let
            zipName = pkgs.lib.concatStringsSep "_" group;
          in
          pkgs.stdenv.mkDerivation {
            inherit pname;
            version = "1.0";
            src = ./.;
            dontConfigure = true;
            buildInputs = with pkgs; [ zip ];
            buildPhase = ''
              zip ${zipName}.zip README ex*.sql
            '';
            installPhase = ''
              mkdir -p $out
              install -Dm644 ${zipName}.zip $out
            '';
          };
        defaultPackage = packages.${pname};

        devShell =
          pkgs.mkShell { buildInputs = with pkgs; [ pgformatter sqls postgresql zip unzip ]; };
      });
}