database-design

Best way to save type of class in database?

北慕城南 提交于 2019-12-29 09:06:16
问题 What is a good way to denote "type" in database? I have a base class Action which is inherited by numerous child classes. Action has members like Id , Name etc all which corresponds to equivalent columns in a table in the database called action . So action table looks like this: id | name | type The type column denotes what action it is. In my code they correspond to the child classes deriving from parent Action . Now how do I save the type of class to the type field in database ? The type

Relation between type, attribute, instance and value

自古美人都是妖i 提交于 2019-12-29 09:02:57
问题 I'm developing an Java-application which stores its data via Hibernate in a database. One feature of this application is to define templates like types, etc. for reuse. For instance the type has attributes and you can create instances of an type, which has values for the attributes. The problem is, that I don't know how to ensure that only values for attributes can assigned which the type defines. In my solution there is a redundancy which cause the problem, but I don't know how to remove it.

App Engine: Structured Property vs Reference Property for one-to-many relationship

折月煮酒 提交于 2019-12-29 08:33:09
问题 My background with designing data stores comes from Core Data on iOS, which supports properties having a one-to-many relationship with another entity. I'm working on an App Engine project which currently has three entity types: User , which represents a person using the app. Project , which represents a project. A User may be associated with many projects. Post , which is the main content behind a Project . A Project may have many posts. Currently, User has a property, projects , that is a

How to best manage historical lookup values in a database?

▼魔方 西西 提交于 2019-12-29 08:19:13
问题 Overview An incident database that will have a number of columns holding an ID for a record held in a lookup table. The problem I'm trying to solve I need to come up with a robust solution to manage historical data where some fields hold lookup IDs. I've listed my proposed solutions as well as alternatives. I would like to know from other developers if they manage these scenarios in a similar way in their projects. Perhaps you have a better approach? Database : Oracle 10g Column : Department

How to keep foreign key relations consistent in a “diamond-shaped” system of relationships

限于喜欢 提交于 2019-12-29 07:04:27
问题 Consider this situation: a Car is bought from a Salesperson . A Salesperson works at a Showroom (and at only one Showroom). A Showroom is affiliated to a Manufacturer , and only sells cars made by that Manufacturer. At the same time, a Car is of a particular Model , and a Model is made by a Manufacturer. Restriction R: A Car's Model's Manufacturer must be the same Manufacturer as the Car's Salesperson's Showroom's affiliated Manufacturer. The diagram shows the obvious foreign key

How to keep foreign key relations consistent in a “diamond-shaped” system of relationships

纵饮孤独 提交于 2019-12-29 07:04:20
问题 Consider this situation: a Car is bought from a Salesperson . A Salesperson works at a Showroom (and at only one Showroom). A Showroom is affiliated to a Manufacturer , and only sells cars made by that Manufacturer. At the same time, a Car is of a particular Model , and a Model is made by a Manufacturer. Restriction R: A Car's Model's Manufacturer must be the same Manufacturer as the Car's Salesperson's Showroom's affiliated Manufacturer. The diagram shows the obvious foreign key

org.hibernate.MappingException: Repeated column in mapping for entity

房东的猫 提交于 2019-12-29 06:25:18
问题 I am doing a simple Poll system. I have 2 tables: Person : ID, Name, Surname Vote : ID, Vote (Boolean), VoterID (This is actually FK_PersonID ), PersonID (This is actually FK_PersonID as well). I need to be able to identify who cast the vote as well as who the vote was for - using the people stored in the Person table for both of these needs. The table Person contains user details of people that can "Vote" as well as be "Voted for". People are allowed to decide whether they want to vote for

Look-up vs relationship Microsoft Access

风格不统一 提交于 2019-12-29 05:32:06
问题 I'm developing a Microsoft Access 2013 based information system. One of the client's demands was to simplify the data entry process by using combo box with available values. For example, instead of entering agentID the client asked to let the user choose agent name from the combo box, the same logic with other similar fields. In brief: I need to avoid as much as possible the need to enter the values ID and let to user choose them from the combo box. Microsoft Access has a built-in lookup

Database design: one huge table or separate tables?

我们两清 提交于 2019-12-29 04:30:11
问题 Currently I am designing a database for use in our company. We are using SQL Server 2008. The database will hold data gathered from several customers. The goal of the database is to acquire aggregate benchmark numbers over several customers. Recently, I have become worried with the fact that one table in particular will be getting very big. Each customer has approximately 20.000.000 rows of data, and there will soon be 30 customers in the database (if not more). A lot of queries will be done

Ternary (and n-ary) relationships in Hibernate

老子叫甜甜 提交于 2019-12-29 04:28:33
问题 Q 1) How can we model a ternary relationship using Hibernate? For example, how can we model the ternary relationship presented here using Hibernate (or JPA)? NOTE : I know that JPA 2 has added some constructs for building ternary relationships using maps. However, this question assumes JPA 1 or Hibernate 3.3.x and I don't like to use maps to model this. (source: grussell.org) (source: grussell.org) Ideally I prefer my model to be like this: class SaleAssistant { Long id; //... } class