initial commit
This commit is contained in:
71
alumnos/index.php
Normal file
71
alumnos/index.php
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
require_once('../models/alumno.php');
|
||||||
|
$alumnos = Alumno::getAll();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Restaurant</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/css/bootstrap.min.css" integrity="sha384-SI27wrMjH3ZZ89r4o+fGIJtnzkAnFs3E4qz9DIYioCQ5l9Rd/7UAa8DHcaL8jkWt" crossorigin="anonymous">
|
||||||
|
<link rel="stylesheet" href="/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||||
|
<a class="navbar-brand" href="/">Alumnos</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav">
|
||||||
|
<li class="nav-item dropdown active">
|
||||||
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
Alumnos
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
|
<a class="dropdown-item" href="/alumnos/index.php">Lista</a>
|
||||||
|
<a class="dropdown-item" href="/alumnos/registrar.php">Crear</a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">Asignatura</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">Notas</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<div class="container">
|
||||||
|
<p class="display-1">Alumnos</p>
|
||||||
|
<table class="table">
|
||||||
|
<thead class="thead-dark">
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th scope="col">Rut</th>
|
||||||
|
<th scope="col">Nombre</th>
|
||||||
|
<th scope="col">Controles</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach($alumnos as $alumno){?>
|
||||||
|
<tr>
|
||||||
|
<th scope="row"><?php echo $alumno->get_id() ?></th>
|
||||||
|
<td><?php echo $alumno->get_rut() ?></td>
|
||||||
|
<td><?php echo $alumno->get_nombre() ?></td>
|
||||||
|
<td>
|
||||||
|
<a class="btn btn-primary" href="#" role="button">Link</a>
|
||||||
|
<a class="btn btn-primary" href="#" role="button">Link</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php }?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/js/bootstrap.min.js" integrity="sha384-3qaqj0lc6sV/qpzrc1N5DC6i1VRn/HyX4qdPaiEFbn54VjQBEU341pvjz7Dv3n6P" crossorigin="anonymous"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
0
alumnos/modificar.php
Normal file
0
alumnos/modificar.php
Normal file
21
alumnos/register_post.php
Normal file
21
alumnos/register_post.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
require_once('../models/alumno.php');
|
||||||
|
require_once('../rut_validacion.php');
|
||||||
|
|
||||||
|
$rut = $_POST['rut'];
|
||||||
|
if(!validar_rut($rut)){
|
||||||
|
echo "ERROR";
|
||||||
|
header("location: /alumnos/registrar.php");
|
||||||
|
var_dump("OH NO");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$alumno = new Alumno();
|
||||||
|
$alumno->set_rut($_POST['rut']);
|
||||||
|
$alumno->set_nombre($_POST['nombre']);
|
||||||
|
|
||||||
|
if($alumno->save())
|
||||||
|
{
|
||||||
|
header("location: /alumnos/index.php");
|
||||||
|
}
|
||||||
|
?>
|
||||||
54
alumnos/registrar.php
Normal file
54
alumnos/registrar.php
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Restaurant</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/css/bootstrap.min.css" integrity="sha384-SI27wrMjH3ZZ89r4o+fGIJtnzkAnFs3E4qz9DIYioCQ5l9Rd/7UAa8DHcaL8jkWt" crossorigin="anonymous">
|
||||||
|
<link rel="stylesheet" href="/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||||
|
<a class="navbar-brand" href="/">Universidad</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav">
|
||||||
|
<li class="nav-item dropdown active">
|
||||||
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
Alumnos
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
|
<a class="dropdown-item" href="/clientes/index.php">Lista</a>
|
||||||
|
<a class="dropdown-item" href="/clientes/registrar.php">Crear</a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">Asignaturas</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">Notas</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<div class="container">
|
||||||
|
<p class="display-1">Registrar Alumno</p>
|
||||||
|
<form action="register_post.php" method="post">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="rut">Rut</label>
|
||||||
|
<input type="text" class="form-control" id="rut" name="rut">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="nombre">Nombre</label>
|
||||||
|
<input type="text" class="form-control" id="nombre" name="nombre">
|
||||||
|
</div>
|
||||||
|
<input type="submit" class="btn btn-primary" value="Enviar">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/js/bootstrap.min.js" integrity="sha384-3qaqj0lc6sV/qpzrc1N5DC6i1VRn/HyX4qdPaiEFbn54VjQBEU341pvjz7Dv3n6P" crossorigin="anonymous"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
51
db.php
Normal file
51
db.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
class DB {
|
||||||
|
private $server = 'localhost';
|
||||||
|
private $user= 'root';
|
||||||
|
private $pass= 'ff9800s_a_d';
|
||||||
|
private $db= 'alumnos';
|
||||||
|
|
||||||
|
private $options = [
|
||||||
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||||
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||||
|
PDO::ATTR_EMULATE_PREPARES => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
private $dsn;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->dsn = "mysql:host=".$this->server.";dbname=".$this->db;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function query($query, ...$params)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$pdo = new PDO($this->dsn, $this->user, $this->pass, $this->options);
|
||||||
|
$stmt = $pdo->prepare($query);
|
||||||
|
$stmt->execute($params);
|
||||||
|
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
catch(PDOException $e)
|
||||||
|
{
|
||||||
|
throw new \PDOException($e->getMessage(), (int)$e->getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dml($dml, ...$params)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$pdo = new PDO($this->dsn, $this->user, $this->pass, $this->options);
|
||||||
|
$stmt = $pdo->prepare($dml);
|
||||||
|
$stmt->execute($params);
|
||||||
|
return $stmt->rowCount();
|
||||||
|
}
|
||||||
|
catch(PDOException $e)
|
||||||
|
{
|
||||||
|
throw new \PDOException($e->getMessage(), (int)$e->getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
40
index.php
Normal file
40
index.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Restaurant</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/css/bootstrap.min.css" integrity="sha384-SI27wrMjH3ZZ89r4o+fGIJtnzkAnFs3E4qz9DIYioCQ5l9Rd/7UAa8DHcaL8jkWt" crossorigin="anonymous">
|
||||||
|
<link rel="stylesheet" href="/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||||
|
<a class="navbar-brand active" href="/">Universidad</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav">
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
Alumnos
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
|
<a class="dropdown-item" href="/alumnos/index.php">Lista</a>
|
||||||
|
<a class="dropdown-item" href="/alumnos/registrar.php">Crear</a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">Asignatura</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">Notas</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/js/bootstrap.min.js" integrity="sha384-3qaqj0lc6sV/qpzrc1N5DC6i1VRn/HyX4qdPaiEFbn54VjQBEU341pvjz7Dv3n6P" crossorigin="anonymous"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
46
models/alumno.php
Normal file
46
models/alumno.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
require_once('../db.php');
|
||||||
|
|
||||||
|
class Alumno
|
||||||
|
{
|
||||||
|
private $id;
|
||||||
|
private $rut;
|
||||||
|
private $nombre;
|
||||||
|
|
||||||
|
public function __construct() {}
|
||||||
|
|
||||||
|
public function set_id($id) { $this->id = $id; }
|
||||||
|
public function get_id() { return $this->id; }
|
||||||
|
public function set_rut($rut) { $this->rut = $rut; }
|
||||||
|
public function get_rut() { return $this->rut; }
|
||||||
|
public function set_nombre($nombre) { $this->nombre = $nombre; }
|
||||||
|
public function get_nombre() { return $this->nombre; }
|
||||||
|
|
||||||
|
public function save()
|
||||||
|
{
|
||||||
|
|
||||||
|
$db = new DB();
|
||||||
|
$result = $db->dml
|
||||||
|
(
|
||||||
|
"insert into alumno (rut, nombre) values (?, ?)",
|
||||||
|
$this->rut, $this->nombre
|
||||||
|
);
|
||||||
|
return $result > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAll() {
|
||||||
|
$db = new DB();
|
||||||
|
$results = $db->query("select * from alumno");
|
||||||
|
|
||||||
|
$alumnos = [];
|
||||||
|
foreach($results as $result) {
|
||||||
|
$alumno = new Alumno();
|
||||||
|
$alumno->set_id($result['id']);
|
||||||
|
$alumno->set_rut($result['rut']);
|
||||||
|
$alumno->set_nombre($result['nombre']);
|
||||||
|
array_push($alumnos, $alumno);
|
||||||
|
}
|
||||||
|
return $alumnos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
38
models/pedido.php
Normal file
38
models/pedido.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
require_once('../db.php');
|
||||||
|
|
||||||
|
class Reserva
|
||||||
|
{
|
||||||
|
private $id;
|
||||||
|
private $fecha;
|
||||||
|
private $estado;
|
||||||
|
private $plato_id;
|
||||||
|
private $cliente_id;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_id() { return $this->id; }
|
||||||
|
public function get_fecha() { return $this->fecha; }
|
||||||
|
public function get_estado() { return $this->estado; }
|
||||||
|
public function get_plato_id() { return $this->plato_id; }
|
||||||
|
public function get_cliente_id() { return $this->cliente_id; }
|
||||||
|
public function set_id($id) { $this->id = $id}
|
||||||
|
public function set_fecha($fecha) { $this->fecha = $fecha; }
|
||||||
|
public function set_estado($estado) { $this->estado = $estado; }
|
||||||
|
public function set_plato_id($plato_id) { $this->plato_id = $plato_id; }
|
||||||
|
public function set_cliente_id($cliente_id) { $this->cliente_id = $cliente_id; }
|
||||||
|
|
||||||
|
public function save()
|
||||||
|
{
|
||||||
|
$db = new DB();
|
||||||
|
$result = $db->dml
|
||||||
|
(
|
||||||
|
"insert into plato (id, fecha, estado, plato, cliente) values (?, ?, ?, ?, ?)",
|
||||||
|
$this->id, $this->fecha, $this->estado, $this->plato_id, $this->cliente_id
|
||||||
|
);
|
||||||
|
return $result > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
35
models/plato.php
Normal file
35
models/plato.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
require_once('../db.php');
|
||||||
|
|
||||||
|
class Plato
|
||||||
|
{
|
||||||
|
private $id;
|
||||||
|
private $nombre;
|
||||||
|
private $descripcion;
|
||||||
|
private $imagen;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_id() { return $this->id; }
|
||||||
|
public function set_id($id) { $this->id = $id; }
|
||||||
|
public function get_nombre() { return $this->nombre; }
|
||||||
|
public function set_nombre($nombre) { $this->nombre = $nombre; }
|
||||||
|
public function get_descripcion() { return $this->descripcion; }
|
||||||
|
public function set_descripcion($descripcion) { $this->descripcion = $descripcion; }
|
||||||
|
public function get_imagen() { return $this->imagen; }
|
||||||
|
public function set_imagen($imagen) { $this->imagen = $imagen; }
|
||||||
|
|
||||||
|
public function save()
|
||||||
|
{
|
||||||
|
$db = new DB();
|
||||||
|
$result = $db->dml
|
||||||
|
(
|
||||||
|
"insert into plato (id, nombre, descripcion, imagen) values (?, ?, ?, ?)",
|
||||||
|
$this->id, $this->nombre, $this->descripcion, $this->imagen
|
||||||
|
);
|
||||||
|
return $result > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
32
models/reserva.php
Normal file
32
models/reserva.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
require_once('../db.php');
|
||||||
|
|
||||||
|
class Reserva
|
||||||
|
{
|
||||||
|
private $id;
|
||||||
|
private $fecha;
|
||||||
|
private $cliente_id;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_id() { return $this->id; }
|
||||||
|
public function set_id($id) { $this->id = $id; }
|
||||||
|
public function get_fecha() { return $this->fecha; }
|
||||||
|
public function set_fecha($fecha) { $this->fecha = $fecha; }
|
||||||
|
public function get_cliente_id() { return $this->cliente_id; }
|
||||||
|
public function set_cliente_id($cliente_id) { $this->cliente_id = $cliente_id; }
|
||||||
|
|
||||||
|
public function save()
|
||||||
|
{
|
||||||
|
$db = new DB();
|
||||||
|
$result = $db->dml
|
||||||
|
(
|
||||||
|
"insert into reserva (id, fecha, cliente) values (?, ?, ?)",
|
||||||
|
$this->id, $this->fecha, $this->cliente_id
|
||||||
|
);
|
||||||
|
return $result > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
21
rut_validacion.php
Normal file
21
rut_validacion.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function validar_rut($rut){
|
||||||
|
$rut = preg_replace('/[^k0-9]/i', '', $rut);
|
||||||
|
$digito_verificador = substr($rut, -1);
|
||||||
|
$numero = substr($rut, 0, strlen($rut)-1);
|
||||||
|
$i = 2;
|
||||||
|
$suma = 0;
|
||||||
|
foreach(array_reverse(str_split($numero)) as $v)
|
||||||
|
{
|
||||||
|
if($i==8) $i = 2;
|
||||||
|
$suma += $v * $i;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$digito_verificador_calculado = 11 - ($suma % 11);
|
||||||
|
|
||||||
|
if($digito_verificador_calculado == 11) $dvr = 0;
|
||||||
|
if($digito_verificador_calculado == 10) $digito_verificador_calculado = 'K';
|
||||||
|
return $digito_verificador_calculado == strtoupper($digito_verificador);
|
||||||
|
}
|
||||||
|
?>
|
||||||
32
sql/database.sql
Normal file
32
sql/database.sql
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
drop database if exists alumnos;
|
||||||
|
create database alumnos;
|
||||||
|
|
||||||
|
use alumnos;
|
||||||
|
|
||||||
|
create table alumno (
|
||||||
|
id int primary key auto_increment,
|
||||||
|
rut varchar(255) not null,
|
||||||
|
nombre varchar(255) not null
|
||||||
|
);
|
||||||
|
|
||||||
|
create table asignatura (
|
||||||
|
id int primary key auto_increment,
|
||||||
|
nombre varchar(255) not null
|
||||||
|
);
|
||||||
|
|
||||||
|
create table alumno_asignatura (
|
||||||
|
id int primary key auto_increment,
|
||||||
|
alumno_id int not null,
|
||||||
|
asignatura_id int not null,
|
||||||
|
foreign key (alumno_id) references alumno (id),
|
||||||
|
foreign key (asignatura_id) references asignatura (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
create table nota (
|
||||||
|
id int primary key auto_increment,
|
||||||
|
puntaje_total int not null default 0,
|
||||||
|
puntaje_obtenido int not null default 0,
|
||||||
|
exigencia int not null default 50,
|
||||||
|
alumno_asignatura_id int not null,
|
||||||
|
foreign key (alumno_asignatura_id) references alumno_asignatura (id)
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user