relational-database

Entity and Relationship Set

北慕城南 提交于 2019-12-25 14:05:07
问题 I am confused about "entity set" and "relationship set". I am aware of "entity" and "relationship". Is there any clear example for entity set and relationship set which shows the real use cases of these terms? ___________ /\ ___________ | | / \ | | | Teacher |-------- /Tea \--------| Student | |___________| \che / |___________| \s / \/ In the above diagram Teacher and Student are entities and Teaches is a relationship. 回答1: Originally in Entity-Relationship Modeling: An entity is an

How can I improve this database model?

可紊 提交于 2019-12-25 06:37:36
问题 I'm trying to model the relationship of dvd sales and dvd rentals to a customer. Although I dont think my transction table is correct. If anyone can let me know if I'm goin in the right direction with the design that would be great. 回答1: Here is one way you can design this. I am not a database expert. I have designed databases for small sized applications with few tables. I try (emphasis on try, sometimes I fail to) to be more generic as possible so I am not confined to a corner when there is

MySQL foreign key relations vs mysql_insert_id to relate tables

☆樱花仙子☆ 提交于 2019-12-25 05:19:10
问题 This is for a sort of proof of concept draft to get things working, but don't want to have completely crap code. For my database, I tried to get true foreign key relations going using innoDB, but couldn't get it. Instead of using foreign keys, I decided to just pull mysql_insert_id() after inserts, saving it as a variable, then putting that variable into the related table. Is this horrible? Everything seems to work well, and I'm able to connect and relate ID's as needed. What benefits would

Implications of Supertype and Subtype

好久不见. 提交于 2019-12-25 05:12:07
问题 Is it bad to implement supertype and subtype to the entire data in a database? I need some advice on this before moving to this direction... For instance, I have these tables as objects and they are related, users pages images entities table as the supertype entity_id entity_type 1 page 2 page 3 user 4 user 5 image 6 image users table user_id entity_id 1 3 2 4 pages table page_id entity_id 1 1 2 2 images table image_id entity_id 1 5 2 6 here is the table to map images table with entities

MySQL foreign key causing table to drop

落爺英雄遲暮 提交于 2019-12-25 04:56:07
问题 had an issue before with this code which was resolved and caused the table to work but now i am receiving error 1005 and the table cannot be created due to the fk here is the code for the first table SET FOREIGN_KEY_CHECKS = 0; DROP TABLE IF EXISTS Customer; CREATE TABLE Customer ( CustomerNumber int NOT NULL, CustomerName varchar(255), CustomerAddress varchar(255), CustomerPhoneNumber varchar(255), JoinDate varchar(255), PetName varchar(255), PayScheme varchar(255), PremiumPayDate varchar

How does the optimizer decide between merge join and hash join?

拈花ヽ惹草 提交于 2019-12-25 04:18:09
问题 Database System Concepts introduce several ways to implement a join operation. Two of them are merge join and hash join. I was wondering when the optimizer decides to use a merge join and when a hash join? In particular, from https://stackoverflow.com/a/1114288/156458 hash joins can only be used for equi-joins, but merge joins are more flexible. But Database System Concepts says both are used only for equi joins and natural joins. The merge-join algorithm (also called the sort-merge-join

Access 2010 - display related record in a form

三世轮回 提交于 2019-12-25 04:07:33
问题 I have 2 related tables. Invoice (fields: number, buyer, supplier, etc.) Company - all buyers and suppliers (fields: name,etc.) Buyer ans supplier fields on invoice are referencing same field (company_id from company table) On invoice form, I choose supplier ID from dropdown list and also buyer ID from dropdown list. Task : To make the form little bit readable, I would like to automatically display a name of company after selecting company id in both fields. What I did : I manually dragged

SQL Server - Inserted Table

本小妞迷上赌 提交于 2019-12-25 03:52:14
问题 I am checking the output of the inserted / deleted table using the following trigger, how can I pass on the intercepted UPDATE command to the server after verifying columns? CREATE TRIGGER Test1_LastUpdate ON Test1 INSTEAD OF UPDATE AS SELECT * FROM Inserted SELECT * FROM Deleted GO EDIT: I am looking for a solution that will not need to be changed after schema updates. CREATE TRIGGER Test1_LastUpdate2 ON Test1 INSTEAD OF UPDATE AS --COMMIT UPDATE THAT WAS INTERCEPTED END 回答1: The only way

SQL Server - Inserted Table

非 Y 不嫁゛ 提交于 2019-12-25 03:51:30
问题 I am checking the output of the inserted / deleted table using the following trigger, how can I pass on the intercepted UPDATE command to the server after verifying columns? CREATE TRIGGER Test1_LastUpdate ON Test1 INSTEAD OF UPDATE AS SELECT * FROM Inserted SELECT * FROM Deleted GO EDIT: I am looking for a solution that will not need to be changed after schema updates. CREATE TRIGGER Test1_LastUpdate2 ON Test1 INSTEAD OF UPDATE AS --COMMIT UPDATE THAT WAS INTERCEPTED END 回答1: The only way

Converting an ER diagram to relational model

☆樱花仙子☆ 提交于 2019-12-25 02:50:14
问题 I know how to convert an entity set, relationship, etc. into the relational model but what i wonder is that what should we do when an entire diagram is given? How do we convert it? Do we create a separate table for each relationship, and for each entity set? For example, if we are given the following ER diagram: My solution to this is like the following: //this part includes the purchaser relationship and policies entity set CREATE TABLE Policies ( policyid INTEGER, cost REAL, ssn CHAR(11)