Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trabalho #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exemplo_alunos/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM php:8.1.16-apache

FROM php:8.1.16-apache
RUN docker-php-ext-install pdo pdo_mysql
84 changes: 42 additions & 42 deletions exemplo_alunos/banco.puml
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
@startuml banco

hide circle
skinparam linetype ortho

entity tb_aluno {
* id : int <<PK>>
--
* nome : varchar(100)
* endereco : varchar(200)
* telefone : varchar(11)
* data_nascimento : date
}

entity tb_curso {
* id : int <<PK>>
--
* nome : varchar(100)
* descricao : varchar(200)
* carga_horaria : int
* data_inicio : date
* data_fim : date
}

entity tb_turma {
* id : int <<PK>>
--
* nome : varchar(100)
* id_curso : int <<FK>>
}

entity tb_matricula {
* id : int <<PK>>
--
* id_aluno : int <<FK>>
* id_turma : int <<FK>>
* data_matricula : date
}

tb_curso ||--o{ tb_turma : possui
tb_aluno ||--o{ tb_matricula : possui
tb_turma ||--o{ tb_matricula : possui
@startuml banco
hide circle
skinparam linetype ortho
entity tb_aluno {
* id : int <<PK>>
--
* nome : varchar(100)
* endereco : varchar(200)
* telefone : varchar(11)
* data_nascimento : date
}
entity tb_curso {
* id : int <<PK>>
--
* nome : varchar(100)
* descricao : varchar(200)
* carga_horaria : int
* data_inicio : date
* data_fim : date
}
entity tb_turma {
* id : int <<PK>>
--
* nome : varchar(100)
* id_curso : int <<FK>>
}
entity tb_matricula {
* id : int <<PK>>
--
* id_aluno : int <<FK>>
* id_turma : int <<FK>>
* data_matricula : date
}
tb_curso ||--o{ tb_turma : possui
tb_aluno ||--o{ tb_matricula : possui
tb_turma ||--o{ tb_matricula : possui
@enduml
142 changes: 77 additions & 65 deletions exemplo_alunos/code/db/banco.sql
Original file line number Diff line number Diff line change
@@ -1,65 +1,77 @@
DROP DATABASE IF EXISTS `db_exemplo_alunos`;
CREATE DATABASE `db_exemplo_alunos` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci */;
USE `db_exemplo_alunos`;

DROP TABLE IF EXISTS `tb_aluno`;
CREATE TABLE `tb_aluno` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(100) NOT NULL,
`endereco` varchar(200) NOT NULL,
`telefone` varchar(11) NOT NULL,
`data_nascimento` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

INSERT INTO `tb_aluno` (`id`, `nome`, `endereco`, `telefone`, `data_nascimento`) VALUES
(1, 'Fulano', 'Rua F1', '62987654321', '2010-10-01'),
(2, 'Ciclano', 'Rua C1', '62999222222', '1990-12-30'),
(3, 'Teste3', 'Rua 3', '62991003333', '1993-03-03');

DROP TABLE IF EXISTS `tb_curso`;
CREATE TABLE `tb_curso` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(100) NOT NULL,
`descricao` varchar(200) NOT NULL,
`carga_horaria` int(11) NOT NULL,
`data_inicio` date NOT NULL,
`data_fim` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

INSERT INTO `tb_curso` (`id`, `nome`, `descricao`, `carga_horaria`, `data_inicio`, `data_fim`) VALUES
(1, 'Tec. Teste', 'Curso para teste do CursoDao', 200, '2000-01-30', '2000-03-30'),
(2, 'Tec. Info', 'Técnico em Informática (Teste 1)', 1000, '2011-01-01', '2012-01-01');

DROP TABLE IF EXISTS `tb_matricula`;
CREATE TABLE `tb_matricula` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_aluno` int(11) NOT NULL,
`id_turma` int(11) NOT NULL,
`data_matricula` date NOT NULL,
PRIMARY KEY (`id`),
KEY `id_aluno` (`id_aluno`),
KEY `id_turma` (`id_turma`),
CONSTRAINT `tb_matricula_ibfk_1` FOREIGN KEY (`id_aluno`) REFERENCES `tb_aluno` (`id`),
CONSTRAINT `tb_matricula_ibfk_2` FOREIGN KEY (`id_turma`) REFERENCES `tb_turma` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

INSERT INTO `tb_matricula` (`id`, `id_aluno`, `id_turma`, `data_matricula`) VALUES
(1, 3, 2, '2020-01-01'),
(2, 2, 1, '2023-05-01');

DROP TABLE IF EXISTS `tb_turma`;
CREATE TABLE `tb_turma` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(100) NOT NULL,
`id_curso` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `id_curso` (`id_curso`),
CONSTRAINT `tb_turma_ibfk_1` FOREIGN KEY (`id_curso`) REFERENCES `tb_curso` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

INSERT INTO `tb_turma` (`id`, `nome`, `id_curso`) VALUES
(1, 'Turma 2009', 1),
(2, 'Turma de 2010', 2),
(3, '2a', 2);
DROP DATABASE IF EXISTS `db_exemplo_alunos`;
CREATE DATABASE `db_exemplo_alunos` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci */;
USE `db_exemplo_alunos`;

DROP TABLE IF EXISTS `tb_aluno`;
CREATE TABLE `tb_aluno` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(100) NOT NULL,
`endereco` varchar(200) NOT NULL,
`telefone` varchar(11) NOT NULL,
`data_nascimento` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

INSERT INTO `tb_aluno` (`id`, `nome`, `endereco`, `telefone`, `data_nascimento`) VALUES
(1, 'Fulano', 'Rua F1', '62987654321', '2010-10-01'),
(2, 'Ciclano', 'Rua C1', '62999222222', '1990-12-30'),
(3, 'Teste3', 'Rua 3', '62991003333', '1993-03-03');

DROP TABLE IF EXISTS `tb_curso`;
CREATE TABLE `tb_curso` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(100) NOT NULL,
`descricao` varchar(200) NOT NULL,
`carga_horaria` int(11) NOT NULL,
`data_inicio` date NOT NULL,
`data_fim` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

INSERT INTO `tb_curso` (`id`, `nome`, `descricao`, `carga_horaria`, `data_inicio`, `data_fim`) VALUES
(1, 'Tec. Teste', 'Curso para teste do CursoDao', 200, '2000-01-30', '2000-03-30'),
(2, 'Tec. Info', 'Técnico em Informática (Teste 1)', 1000, '2011-01-01', '2012-01-01');

DROP TABLE IF EXISTS `tb_turma`;
CREATE TABLE `tb_turma` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(100) NOT NULL,
`id_curso` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `id_curso` (`id_curso`),
CONSTRAINT `tb_turma_ibfk_1` FOREIGN KEY (`id_curso`) REFERENCES `tb_curso` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

INSERT INTO `tb_turma` (`id`, `nome`, `id_curso`) VALUES
(1, 'Turma 2009', 1),
(2, 'Turma de 2010', 2),
(3, '2a', 2);

DROP TABLE IF EXISTS `tb_login`;
CREATE TABLE `tb_login` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`usuario` varchar(200) NOT NULL,
`senha` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

INSERT INTO `tb_login` (`id`, `usuario`, `senha`) VALUES
(1, 'daianny', '123456');

DROP TABLE IF EXISTS `tb_matricula`;
CREATE TABLE `tb_matricula` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_aluno` int(11) NOT NULL,
`id_turma` int(11) NOT NULL,
`data_matricula` date NOT NULL,
PRIMARY KEY (`id`),
KEY `id_aluno` (`id_aluno`),
KEY `id_turma` (`id_turma`),
CONSTRAINT `tb_matricula_ibfk_1` FOREIGN KEY (`id_aluno`) REFERENCES `tb_aluno` (`id`),
CONSTRAINT `tb_matricula_ibfk_2` FOREIGN KEY (`id_turma`) REFERENCES `tb_turma` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

INSERT INTO `tb_matricula` (`id`, `id_aluno`, `id_turma`, `data_matricula`) VALUES
(1, 3, 2, '2020-01-01'),
(2, 2, 1, '2023-05-01');

38 changes: 19 additions & 19 deletions exemplo_alunos/code/db/conexao.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?php

class Conexao
{
private $host = 'mariadb-server';
private $db = 'db_exemplo_alunos';
private $user = 'root';
private $password = '123';

public function conectar()
{
try {
$conexao = new PDO("mysql:host=$this->host;dbname=$this->db", $this->user, $this->password);
return $conexao;
} catch (PDOException $e) {
echo $e;
}
}
}
<?php
class Conexao
{
private $host = 'mariadb-server';
private $db = 'db_exemplo_alunos';
private $user = 'root';
private $password = '123';
public function conectar()
{
try {
$conexao = new PDO("mysql:host=$this->host;dbname=$this->db", $this->user, $this->password);
return $conexao;
} catch (PDOException $e) {
echo $e;
}
}
}
58 changes: 29 additions & 29 deletions exemplo_alunos/code/model/aluno.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<?php

class Aluno
{
private $id;
private $nome;
private $endereco;
private $telefone;
private $data_nascimento;

public function __construct($id, $nome, $endereco, $telefone, $data_nascimento)
{
$this->id = $id;
$this->nome = $nome;
$this->endereco = $endereco;
$this->telefone = $telefone;
$this->data_nascimento = $data_nascimento;
}

public function __get($atributo)
{
return $this->$atributo;
}

public function __set($atributo, $valor)
{
$this->$atributo = $valor;
}
}
<?php
class Aluno
{
private $id;
private $nome;
private $endereco;
private $telefone;
private $data_nascimento;
public function __construct($id, $nome, $endereco, $telefone, $data_nascimento)
{
$this->id = $id;
$this->nome = $nome;
$this->endereco = $endereco;
$this->telefone = $telefone;
$this->data_nascimento = $data_nascimento;
}
public function __get($atributo)
{
return $this->$atributo;
}
public function __set($atributo, $valor)
{
$this->$atributo = $valor;
}
}
Loading